Skip to content

perf(http): reduce data transfer when using HTTP caching#52347

Closed
alan-agius4 wants to merge 2 commits intoangular:mainfrom
alan-agius4:http-cache-
Closed

perf(http): reduce data transfer when using HTTP caching#52347
alan-agius4 wants to merge 2 commits intoangular:mainfrom
alan-agius4:http-cache-

Conversation

@alan-agius4
Copy link
Copy Markdown
Contributor

This commit reduces the property size in the http transfer cache to reduce the page payload.

Before

<script id="ng-state" type="application/json">
{
  "4155228514": {
    "body": "....",
    "headers": {},
    "status": 200,
    "statusText": "OK",
    "url": "http://foo.com/assets/media.json",
    "responseType": "json"
  },
}
</script>

Now

<script id="ng-state" type="application/json">
{
  "4155228514": {
    "b": "....",
    "h": {},
    "s": 200,
    "st": "OK",
    "u": "http://foo.com/assets/media.json",
    "rt": "json"
  },
}
</script>

@HyperLife1119
Copy link
Copy Markdown
Contributor

How about using tuples?

@alan-agius4
Copy link
Copy Markdown
Contributor Author

How about using tuples?

I went with a similar approach that is used for other things like hydration. Also with tuples, it feel like it would be harder to visually read what is written in the cache.

@alan-agius4 alan-agius4 added area: common/http Issues related to HTTP and HTTP Client target: patch This PR is targeted for the next patch release labels Oct 24, 2023
@ngbot ngbot bot added this to the Backlog milestone Oct 24, 2023
@alan-agius4 alan-agius4 added the area: server Issues related to server-side rendering label Oct 24, 2023
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 24, 2023
@alan-agius4 alan-agius4 marked this pull request as ready for review October 24, 2023 14:29
This commit reduces the property size in the http transfer cache to reduce the page payload.

Before
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "body": "....",
    "headers": {},
    "status": 200,
    "statusText": "OK",
    "url": "http://foo.com/assets/media.json",
    "responseType": "json"
  },
}
</script>
```

Now
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "b": "....",
    "h": {},
    "s": 200,
    "st": "OK",
    "u": "http://foo.com/assets/media.json",
    "rt": "json"
  },
}
</script>
```
Copy link
Copy Markdown
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 👍

@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 24, 2023
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker target: rc This PR is targeted for the next release-candidate and removed target: patch This PR is targeted for the next patch release labels Oct 24, 2023
@dylhunn
Copy link
Copy Markdown
Contributor

dylhunn commented Oct 24, 2023

This PR was merged into the repository by commit c5e30f1.

@dylhunn dylhunn closed this in c5e30f1 Oct 24, 2023
dylhunn pushed a commit that referenced this pull request Oct 24, 2023
This commit reduces the property size in the http transfer cache to reduce the page payload.

Before
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "body": "....",
    "headers": {},
    "status": 200,
    "statusText": "OK",
    "url": "http://foo.com/assets/media.json",
    "responseType": "json"
  },
}
</script>
```

Now
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "b": "....",
    "h": {},
    "s": 200,
    "st": "OK",
    "u": "http://foo.com/assets/media.json",
    "rt": "json"
  },
}
</script>
```

PR Close #52347
@alan-agius4 alan-agius4 deleted the http-cache- branch October 25, 2023 05:07
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 25, 2023
ChellappanRajan pushed a commit to ChellappanRajan/angular that referenced this pull request Jan 23, 2024
This commit reduces the property size in the http transfer cache to reduce the page payload.

Before
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "body": "....",
    "headers": {},
    "status": 200,
    "statusText": "OK",
    "url": "http://foo.com/assets/media.json",
    "responseType": "json"
  },
}
</script>
```

Now
```html
<script id="ng-state" type="application/json">
{
  "4155228514": {
    "b": "....",
    "h": {},
    "s": 200,
    "st": "OK",
    "u": "http://foo.com/assets/media.json",
    "rt": "json"
  },
}
</script>
```

PR Close angular#52347
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: common/http Issues related to HTTP and HTTP Client area: server Issues related to server-side rendering target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants