I want to be able to cache certain javascript files and some images, in order to speed up the pageload, however I do not want to cache index.php, because a part of the page is generated with php, and different content is generated with different users. (The user ID is retrieved from the URL: index.php?id=301050example).
My problem is, that by default the index.php file is somehow always cached.
I need to be able to prevent the caching of any php files.
I have tried putting this in the file:
<!DOCTYPE html>
<?php
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");
?>
<html lang="nl" manifest="cache.appcache">
and
<!DOCTYPE html>
<html lang="nl" manifest="cache.appcache">
<meta http-equiv="cache-control" content="m`enter code here`ax-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
However with both these options the browser still loaded the index.php?id=301050example file from cache.
The manifest file looks like this:
CACHE MANIFEST
# 31 - 08 - 2015 v0.01
NETWORK:
*
index.php
How can I do this? Thank you in advance!
You simply should use htaccess for the caching properties. Here is an example :
RewriteEngine on
# Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 10 minutes"
</IfModule>
You can generate one here (using the caching section).