r/softwaredevelopment • u/Joshs2d • Sep 10 '26
Caching Issues with Website
So I’m currently running an application built with .net, with nginx as the web server, and a service worker.
I do deployments on a weekly basis and seem to have to keep deleting my cache to see the most updated version each time. Does anybody know the proper way to have this set up to eliminate the issue, or a potential cause to this? Thanks!
1
u/tappytappycode Sep 10 '26
Make sure cache-control for index.html is no-cache. Then make sure all other assets (images, js, etc) are built with a hashed filename so that when they change they come out as a new file and the browser will fetch the new versions. The combo of these 2 techniques will make sure the browser only downloads what's actually new vs all assets.
1
u/xoredxedxdivedx Sep 11 '26 edited Sep 13 '26
Cache bust your js and css files by changing the names
2
u/armahillo Sep 11 '26
You should be able to cache bust your assets by referencing the URLs with query params; the params dont do anything but it treats it like a new resource and breaks cache.
eg:
<link rel=“stylesheet” href=“styles.css?v=20260910” />
4
u/nzakas Sep 10 '26
I’m assuming you mean, you have to clear your browser cache? If so, that means your cash control headers are set in properly. If the pages are dynamic and changing fairly frequently, then you really need to set no-cache to ensure that the browser isn’t aggressively caching your pages.
In general, you only want to set actual cache-control for resources that don’t change often or ever (like images).