You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Astro v5.1.4
Node v18.20.3
System Linux (x64)
Package Manager unknown
Output static
Adapter @astrojs/node
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
According to https://docs.astro.build/en/guides/server-islands/#caching, we should be using cache-control to enforce caching of server island responses. However, prop encryption uses a new IV for every encryption, thus even if you send the same exact props in two different renders of the same server island, they will have different encryptions of the same props, and thus won't be cacheable. See stackblitz for an example - components that don't receive ANY props receive an encryption of the JSON.stringified empty object {}. Because this gets reencrypted with a different IV each time, each GET request has a different query string.
Server islands included from prerendered pages do use the same encryption each time they get downloaded (because they only get rendered once), but that is per-route, and thus you can't cache-invalidate every instance of the same component across different routes because you don't know the right key.
You can see an example in the stackblitz - if you watch the server islands requests in devtools, you'll see that on refresh each of them get served with a new URL each time, even though NoPropIsland has no props to encrypt.
I believe the right way to fix this would be for components with no props, don't send any encrypted props, allowing for direct caching and programmatic cache invalidation.
What's the expected result?
Islands which aren't passed any props should have a deterministic URL, allowing for effective caching and cache invalidation.
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
According to https://docs.astro.build/en/guides/server-islands/#caching, we should be using
cache-control
to enforce caching of server island responses. However, prop encryption uses a new IV for every encryption, thus even if you send the same exact props in two different renders of the same server island, they will have different encryptions of the same props, and thus won't be cacheable. See stackblitz for an example - components that don't receive ANY props receive an encryption of the JSON.stringified empty object {}. Because this gets reencrypted with a different IV each time, each GET request has a different query string.Server islands included from prerendered pages do use the same encryption each time they get downloaded (because they only get rendered once), but that is per-route, and thus you can't cache-invalidate every instance of the same component across different routes because you don't know the right key.
You can see an example in the stackblitz - if you watch the server islands requests in devtools, you'll see that on refresh each of them get served with a new URL each time, even though
NoPropIsland
has no props to encrypt.I believe the right way to fix this would be for components with no props, don't send any encrypted props, allowing for direct caching and programmatic cache invalidation.
What's the expected result?
Islands which aren't passed any props should have a deterministic URL, allowing for effective caching and cache invalidation.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-xcrq2rav?file=src%2Fpages%2Findex.astro
Participation
The text was updated successfully, but these errors were encountered: