When developing frontend sometimes i use NodeJs and Xampp as servers. Sometimes Caching of static files becomes a problem such as styles dont update even though the css files are modified. So i needed to disable the caching.
XAMPP Server
Edit httpd.conf
([xampp folder]/apache/conf/http.conf) file and add following at the end:
# Don't cache html, htm, js, css
<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>
NodeJS Server
Use nocache
module.
pnpm i nocache
const nocache = require('nocache');
app.use(nocache());
OR
Use set etag
to false
app.set('etag', false);
Top comments (0)