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

(adapter-node) Set cache header for the /static files #11875

Closed
hyunbinseo opened this issue Feb 20, 2024 · 4 comments
Closed

(adapter-node) Set cache header for the /static files #11875

hyunbinseo opened this issue Feb 20, 2024 · 4 comments

Comments

@hyunbinseo
Copy link
Contributor

hyunbinseo commented Feb 20, 2024

Describe the problem

The Node.js adapter sets the cache-control to the /_app/immutable files only.

if (pathname.startsWith(`/${manifest.appPath}/immutable/`) && res.statusCode === 200) {
res.setHeader('cache-control', 'public,max-age=31536000,immutable');
}

Files in the /static directory - which are copied to the root of the /_app directory - are not cached by the client.

Describe the proposed solution

  • Provide an adapter option to set the max-age value.
  • Set a default cache-control for the /static assets.

Alternatives considered

No response

Importance

nice to have

Additional Information

@brunnerh
Copy link
Member

Caching these by default is not a good idea because they have fixed paths so cache busting is not an option.
(Other assets automatically get a hash which makes their caching safe.)

@hyunbinseo
Copy link
Contributor Author

@brunnerh I've crossed-out that option.

For additional context for the readers:

import background from '$lib/static/background.svg';

// Becomes /_app/immutable/assets/background.CKwt2LG5.svg

This is why imported static assets can have a cache max-age of 1yr.


Still I do hope there was an option to enable caching manually.

The /static directory is basically useless as of now.

@Conduitry
Copy link
Member

Duplicate of (part of) #3194.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2024
@hyunbinseo
Copy link
Contributor Author

My bad. I've actually 👍 one of the comments in that issue.

Note: With the cache-control header keyword, the issue is listed on the 4th page.

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

No branches or pull requests

3 participants