If Nginx in front of Apache and configured to quickly return statics (CSS, JS, images), and Apache control is not even transferred. Therefore, the settings from .htaccess do not affect the headers, and Nginx often set up for long-term caching:
location ~* ^.+\.(jpg|jpeg|gif|png|css|js|bmp|txt)$ { access_log off; expires 14d; # кеширование в браузере на 14 дней break; }
The first thing to find out is exactly which response headers are sent from the web server. This can be done in the Network tab in the Chrome Developer Console or Сеть in Firefox. Next, we filter by the .css or .js mask and pay attention to the headers:
Expires (the flaw is that the client may have the wrong time) andCache-Control (deprived of this disadvantage).
In the Chrome developer tools, in the Size column, the inscriptions from disk cache and from memory cache just indicate that the resource is being loaded from the cache. And the option Disable cache completely disables the cache, resources are always loaded from the server, but only while the developer tools are open.
Via curl:
curl -I "http://site.ru/js/scrips.js"
To prevent caching, it should be:
Cache-Control: no-cache, no-store, must-revalidate
or
Cache-Control: max-age=0
or Expires indicates a date in the past (minus 1 year, for example).
To understand whether Apache is involved in the formation of the server's response, you can put an additional header, through the same .htaccess :
# Ставим заголовок для понимания Header set BackServer "Apache"
If it is not possible to configure the web server (as in a given question), the file should contain the date of its modification in the form of a GET parameter, for example, like this:
<script src="/js/scrips.js?<?=date('ymdHis', filemtime($_SERVER['DOCUMENT_ROOT'] . '/js/scrips.js'))?>"></script>
Caching in this case will also work, but if you change the file, the GET parameter will change, which will force the browser to download the new version.
Response Headers- show them.cache-control: no-cache, no-store, must-revalidate— that's what's on SO. Although your headers due tomax-age=0should also be banned. Waiting for headlines - Total PusherCache-Control: max-age=315360000. What web server cost? - Total Pusher