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

[fix] correct headers for __data.js requests #6809

Closed
wants to merge 3 commits into from

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Sep 14, 2022

Add all headers except cache-control which is always no-store
Fixes #6458
Fixes (?) #6477 <- not sure how to best handle this, conflicting requirements here

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

Add all headers except cache-control which is always no-store
Fixes #6458
Fixes #6477
@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2022

🦋 Changeset detected

Latest commit: 81608b5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

I'm not sure we want to add headers other than set-cookie? There's no way for the application to access them so they're useless at best (except set-cookie and cache-control, which have side-effects).

Given that some platforms sometimes apparently apply default cache-control headers if none are provided, and given that the __id parameter is per-user, I think we need to always apply private, no-store. If we respect max-age and s-maxage it should probably be in the form of a window.__sveltekit_data_ttl value or similar, the same way we cache data inlined into the HTML response.

@dummdidumm
Copy link
Member Author

I'm not well-versed with all the possibilities of headers, but in #6477 on comment asked for setting headers besides the cache-control - don't know if that's sensible.

@homerjam
Copy link

homerjam commented Sep 14, 2022

not rerunning them is ensured differently

So is there another way to ensure data requests are not re-run "unnecessarily" ie. if I don't need fresh data (I was using cache-control header in load before "pluskit")?

Is window.__sveltekit_data_ttl documented somewhere?

@Rich-Harris
Copy link
Member

on comment asked for setting headers besides the cache-control - don't know if that's sensible

Those sec-fetch-mode and sec-fetch-dest headers would have no effect

Is window.__sveltekit_data_ttl documented somewhere?

No, it doesn't exist. If we do implement it, it'll be an internal detail, not something you'd need to be aware of

@dummdidumm
Copy link
Member Author

Closing as obsolete - the no-store part was implemented in another PR and the cache will need a different implementation.

@dummdidumm dummdidumm closed this Sep 20, 2022
@dummdidumm dummdidumm deleted the data-request-headers branch September 20, 2022 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache problem with client-side navigation: the response is now __data.js instead of __data.json
3 participants