Service workers : disable caching (nginx + apache)
Posted: Wed Feb 14, 2018 9:29 am
Service workers enable web developers to create an application cache.
A kind of local cache that is check before a request is sent to the server.
So with service workers it is possible to make a web application offline available.
(It is being pushed rather fanatically by Chrome (Google).)
Service workers are controlled by a javascript file.
By putting a version number in the javascript file, the browser knows when to update the cache.
BUT, if the javascript file is cached... then the new version number is not renewed (because the file is also cached in the disk cache).
So caching should be off for service worker javascript files, but there is no significant difference between ordinairy javascript files and service worker javascript files.
My web server is apache+nginx and I will name all my service worker files "sw.js".
Can I change the nginx configuration to disable caching on all files with the name "sw.js" ?
Alternatively :
I can place service worker javascript files in a directory called "sw" and all files in that directory should have "disable cache headers" .
(Note : I know how to disable caching for 1 specific file in 1 specific location ... My question is how to disable all caches for each file named "sw.js")
A kind of local cache that is check before a request is sent to the server.
So with service workers it is possible to make a web application offline available.
(It is being pushed rather fanatically by Chrome (Google).)
Service workers are controlled by a javascript file.
By putting a version number in the javascript file, the browser knows when to update the cache.
BUT, if the javascript file is cached... then the new version number is not renewed (because the file is also cached in the disk cache).
So caching should be off for service worker javascript files, but there is no significant difference between ordinairy javascript files and service worker javascript files.
My web server is apache+nginx and I will name all my service worker files "sw.js".
Can I change the nginx configuration to disable caching on all files with the name "sw.js" ?
Alternatively :
I can place service worker javascript files in a directory called "sw" and all files in that directory should have "disable cache headers" .
(Note : I know how to disable caching for 1 specific file in 1 specific location ... My question is how to disable all caches for each file named "sw.js")