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

Cache-Control on static files #9

Open
pikanezi opened this issue Jun 28, 2024 · 2 comments
Open

Cache-Control on static files #9

pikanezi opened this issue Jun 28, 2024 · 2 comments

Comments

@pikanezi
Copy link

Hi,

Would it be possible to set a Cache-Control header for the static files? Also, do you know if it would work with Deno Deploy?

Thanks

@dbushell
Copy link
Owner

Yes this can work on Deno Deploy the example is doing so:
https://sveltekit-adapter-deno.deno.dev/

Deno Deploy has a lot of weird support conditions so it just depends what packages and APIs you're using. From my experience it is slow and not a good hosting platform for websites.

Cache-Control headers are set for the immutable SvelteKit static files:

response.headers.set(
'cache-control',
'public, max-age=31536000, immutable'
);

For custom static files it would be too opinionated to add addtional headers.

I don't think other SvelteKit adapters provide an option. The node adapter suggestions making a custom server. You could do that for sveltekit-adapter-deno by copying build/mod.ts.

You could also proxy the server and at headers at a higher level. Cloudflare Workers would be one way to achieve this.

@pikanezi
Copy link
Author

Thanks for the quick answer. It seems svelte does not handle static caching at all so its an issue every adapter faces. I might do further research on this subject and try something of my own.

As for Deno Deploy, We're using it to host a static pre-rendered website and for this use case its fast enough so I wanted to improve its performance even more by providing caching.

Anyway, thank you again 😄

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

2 participants