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

Dev mode with cache control #152

Open
axmad386 opened this issue Jun 22, 2023 · 1 comment
Open

Dev mode with cache control #152

axmad386 opened this issue Jun 22, 2023 · 1 comment

Comments

@axmad386
Copy link

I know in the docs that with dev = true it will traverse the file system on every request. Is it possible to use dev mode but the http response still set the cache control?
It will useful when we want to make public folder contain dynamic asset, we can add another asset to it, but when we access it browser will cache it.

@axmad386
Copy link
Author

axmad386 commented Aug 1, 2023

My workaround is to set dev to true and manage cache control via setHeader something like this

 sirv(public_path(),{
      dev:true,
      setHeaders: (res) => {
        res.setHeader("Cache-Control", "public,max-age=31536000,immutable");
      },
})

this will make sirv still serve the file dynamically but cache control is sent. So browser will cache the file

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

1 participant