nestjs / serve-static

Serve static websites (SPA's) using Nest framework (node.js) šŸ„¦

Home Page:https://nestjs.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to turn off caching for index.html alone but leave caching enabled for other files

Roaders opened this issue Ā· comments

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

It seems that it is not possible to prevent caching of one file

Expected behavior

I would like to prevent caching of my index.html file but cache all other assets such as css and js files

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

I am serving an angular app. All generated files have a hash in the name so they care fine be cached as the name will change between versions. At the moment the index page is cached and it's very hard to get a new version loaded onto a mobile browser. Turning off caching for index.html will mean I get new app versions on mobile browsers but that the large asset files will be cached.

Please provide a minimum reproduction repository.

Not really sure how to do that. This is either a missing feature or missing documentation...

This package is just a minimal wrapper around the express.static middleware (and fastify-static for apps that use Fastify as an HTTP driver). If you need more flexibility, take a look at app.useStaticAssets() method (or express.static directly https://expressjs.com/en/starter/static-files.html)

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.