Answer the question
In order to leave comments, you need to log in
How to set Last-Modified headers via free ssl on Clouflare?
Hi all. I'm trying to set up the Last-Modified, Expires headers so that only modified files are downloaded from the server. Let's say that I corrected some js file, refreshed the page and the modified file was loaded from the server, while other unmodified files returned the 304 Not Modified status.
Without https, you just need to specify expires modified 0;
and everything works as it should. But when the request goes through https, then the headers are apparently lost, since the https connection goes through proxy DNS. (https is free)
In Cloudflare settings under Caching set Browser Cache Expiration to Respect Existing Headers (it's like using headers from the original server)
Then tried specifying headers ignoring framework headers (Laravel)
location ~* \.(css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
sub_filter_last_modified on;
fastcgi_ignore_headers "Cache-Control" "Expires";
proxy_ignore_headers "Cache-Control" "Expires";
add_header Cache-Control "public, max-age=60, s-maxage=60, must-revalidate, proxy-revalidate";
add_header Last-Modified $sent_http_Expires;
proxy_set_header Last-Modified $sent_http_Expires;
fastcgi_pass_header Last-Modified;
if_modified_since exact;
}
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
log_not_found off;
sub_filter_last_modified on;
fastcgi_ignore_headers "Cache-Control";
add_header Cache-Control "public, max-age=30, s-maxage=30, must-revalidate, proxy-revalidate";
proxy_set_header Last-Modified $sent_http_Expires;
proxy_set_header Expires $sent_http_Expires;
fastcgi_pass_header Last-Modified;
fastcgi_pass_header Expires;
if_modified_since exact;
}
Answer the question
In order to leave comments, you need to log in
Headers leave your server regardless of http/https.
If the request goes through Cloudflare, then it can sometimes give data from its cache. If you change a static file (which was previously allowed to be cached), you must either "Purge cache" in Cloudflare, or save the edited file under a different name (or at least access it with a different GET parameter)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question