Happy Sunday,
I am struggling and hair pulling for 3 days (fearing being almost bold by the end of the month) about the cache management on a Bitnami lamp-packaged instance running on Azure on Ubuntu 16.x.
I am engaged in a PHP5 to PHP7 migration of a big system since several weeks, about to complete the task.
My test site using the system can be reached here: https://stephanedeluca.com for you to look at the cache.
Unfortunately, what I see, is that my PHP scripts are not immediately reflecting the changes I make once deployed (simple upload) to the server. And as a consequences, the UX is sometime destroyed by the fact the user often needs to double refresh, and in the worst cases, have to reload everything via the browser.
On the previous system, everything was good, but on this new box, I've got the issue. The box uses php-fpm.
What I achieved so far regarding the resolution of the cache management:
-
from php.ini, I disabled the OPCache; — from the
.htaccess
, I have used mod_expires (I also installed mod_headers and mod_expires) as follows:<ifModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 0 seconds" </ifModule> <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> <ifModule mod_expires.c> ExpiresDefault "access plus 1 years" </ifModule> <ifModule mod_headers.c> #Header append Cache-Control "public" </ifModule> </FilesMatch> <FilesMatch "\.(gif|jpg|jpeg|png)$"> <ifModule mod_expires.c> ExpiresDefault "access plus 1 weeks" </ifModule> <ifModule mod_headers.c> #Header append Cache-Control "public" </ifModule> </FilesMatch> <FilesMatch "\.(xml|json|txt|html|js|css)$"> <ifModule mod_expires.c> ExpiresDefault "access plus 2 hours" </ifModule> <ifModule mod_headers.c> #Header append Cache-Control "proxy-revalidate" </ifModule> </FilesMatch> <filesMatch "\.(php)$"> FileETag None <ifModule mod_headers.c> Header unset ETag #Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" #Header set Expires "Tue, 15 Mar 1966 10:00:00 GMT+1" </ifModule> </filesMatch>
-
all my PHP scripts (via prepend) generate the following headers (right after session_start() is invoked):
// === No caching === session_cache_limiter('private'); session_cache_expire(0); // === Start session (must be after session_cache_X()) session_start(); header('Cache-Control: private, max-age=0, s-max-age=0, no-cache, no-store, must-revalidate', true); header("Last-Modified: $headerNow", true);
While looking at the browser request and response, I see that everything looks good imho:
Request (as reported by Chrome)
Request URL: https://stephanedeluca.com/
Request Method: GET
Status Code: 200 OK (from ServiceWorker)
Referrer Policy: no-referrer-when-downgrade
Response:
Cache-Control: private, max-age=0, s-max-age=0, no-cache, no-store, must-revalidate
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Sun, 28 Apr 2019 12:36:57 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive: timeout=5, max=100
Last-Modified: Sun, 28 Apr 2019 12:36:57 GMT
Pragma: no-cache
Server: Apache
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-Generated-On: Sun, 28 Apr 2019 12:36:57 GMT
X-Powered-By: ZID/Webengine v24.0b27 -- Copyright (c) 1995-2019 MagicApps (http://MgcApps.com) -- All Rights Reserved
Provisional headers are shown
Referer: https://stephanedeluca.com/map.php
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
I've also checked the cache by using https://www.giftofspeed.com/cache-checker/ and the report is as expected.
I am running out of ideas.