Many PHP developers add the no-cache header on top of their PHP pages, so do I, for obvious reasons. Since PHP generated content is usually dynamic, having the browser cache them results in outdated data being presented to the user. To avoid this caching is usually disabled.
<?php
//no cache headers
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
The problem is that due to this header, also my images, javascript files and css files, which are static and thus could (and should) be cached, are also not being cached. This slows down the site a lot.
Is there a way to have no cache on the PHP content, but still have cached js/images/css?
How can this be achieved, assuming I have full access to modify the (linux) server config, HTACCESS and of course, the PHP files themselves?
Or is the whole "no-cache thing" unnecessary for dynamic PHP files? Even when they are url-rewritten to appear extension-less.
header("Expires: Mon, 26 Jul 1990 05:00:00 GMT");
right? – Praveen Kumar Purushothaman