We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Nginx: Can't set Cache-Control header max-age to 0
Nginx: Can't set Cache-Control header max-age to 0
I'm still pretty new to Vesta and having been battling with a caching issue for the last few days:
I'm hosting a PWA and the service worker file must not be cached. I'm using Apache and Nginx as reverse proxy. Server is running Ubuntu 18.04 and using the latest VestaCP
I've set up the domain to use custom templates based on the default templates and including the following:
../templates/web/apache2/pwa.stpl and ../templates/web/apache2/pwa.tpl
and ../templates/web/nginx/pwa.stpl and ../templates/web/nginx/pwa.tpl
but when I view the headers on the service worker file, it still reads:
Would appreciate any ideas - thanks
I'm hosting a PWA and the service worker file must not be cached. I'm using Apache and Nginx as reverse proxy. Server is running Ubuntu 18.04 and using the latest VestaCP
I've set up the domain to use custom templates based on the default templates and including the following:
../templates/web/apache2/pwa.stpl and ../templates/web/apache2/pwa.tpl
Code: Select all
<Files "service-worker.js">
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Files>
Code: Select all
location service-worker.js {
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
expires off;
proxy_no_cache 1;
}
Code: Select all
Accept-Ranges: bytes
Cache-Control: max-age=315360000 <-------
Connection: keep-alive
Content-Length: 964
Content-Type: application/javascript
Date: Sat, 29 Sep 2018 09:34:03 GMT
ETag: "5baf10c0-3c4"
Expires: Thu, 31 Dec 2037 23:55:55 GMT <--------
Last-Modified: Sat, 29 Sep 2018 05:42:24 GMT
Server: nginx
Re: Nginx: Can't set Cache-Control header max-age to 0
Making some progress:
The file that needs to be edited is /home/myuser/conf/web/mydomain.nginx.ssl.conf and the location snippet relating to the service-worker.js file must go ABOVE the more general location clause (and must include the root value or else it will result in a 404) as follows:
The file that needs to be edited is /home/myuser/conf/web/mydomain.nginx.ssl.conf and the location snippet relating to the service-worker.js file must go ABOVE the more general location clause (and must include the root value or else it will result in a 404) as follows:
Code: Select all
location / {
proxy_pass https://x.x.x.x:8443;
location ~ (index.html|service-worker.js)$ {
root /home/myuser/web/mydomain/public_html;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
expires off;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|svg|css|zip|tgz|gz|rar|bz2|exe|pdf|doc|xls|ppt|txt|odt|ods|odp|odf|tar|bmp|rtf|js|mp3|avi|mpeg|flv|html|htm)$ {
root /home/myuser/web/mydomain/public_html;
access_log /var/log/apache2/domains/mydomain.log combined;
access_log /var/log/apache2/domains/mydomain.bytes bytes;
expires max;
try_files $uri @fallback;
}
}