Hello I have added cache to Nginx. But changed static files (css,images) are not updated untill I press F5. That is wrong Maybe you can advice me what to do.
Here is part of server config
server {
listen 80;
server_name 111.111.111.111 sitename.ru;
etag on;
if_modified_since exact;
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|pdf)$
{
root /storage/www;
expires 30d;
add_header Cache-Control 'public';
}
fastcgi_pass unix://var/run/php-fpm/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /storage/www$fastcgi_script_name;
fastcgi_pass_header Last-Modified;
include fastcgi_params;
fastcgi_read_timeout 240s;
fastcgi_send_timeout 240s;
fastcgi_intercept_errors on;
}
Here is header of CSS HTTP/1.1 200 OK Server: nginx/1.6.2 Date: Fri, 03 Jun 2016 22:46:02 GMT Content-Type: text/css Content-Length: 16150 Last-Modified: Fri, 03 Jun 2016 22:06:24 GMT Connection: close ETag: “5751ff60-3f16” Expires: Sun, 03 Jul 2016 22:46:02 GMT Cache-Control: max-age=2592000 Cache-Control: public Accept-Ranges: bytes
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @staszhilnikov,
What you’re describing is the expected behavior because of the way that the cache module works. When a file is sent from the web server it’s given the header (as shown in your update) that the file is valid for 30 days. The easiest solution is to set a shorter window, or to not use the cache at all. That said, if you require the cache for performance reasons you’ll probably have to balance between cache duration, and update time (perhaps a day? or 12 hours?). Please keep in mind that some large networks use ‘edge cache’ services which would mean that even if a specific client hasn’t accessed your site directly, their network may have, and the cache may be in effect.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.