Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Islands have their props uniquely encrypted even if they have no props, leading to uncacheability #12949

Open
1 task done
kaytwo opened this issue Jan 9, 2025 · 0 comments · May be fixed by #12956
Open
1 task done
Labels
needs triage Issue needs to be triaged

Comments

@kaytwo
Copy link
Contributor

kaytwo commented Jan 9, 2025

Astro Info

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.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-xcrq2rav?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant