Different cache settings per filetype
Posted: Mon Mar 10, 2008 5:37 am
Hello all,
I have a website that requires login and I loading the pages takes too long (see image below).
Now the page roughly consists of:
- The actual page: training.xml.php
- An external stylesheet: allStyles.css.php
- An external javascript: allScripts.js.php
- Some images The main pages of the program (in this case training.xml.php) change very frequently, so these may NOT be cached.
The stylesheet and javascript are generated dynamically but remain the same throughout the session, so these may be cached.
I have not found a way that lets the browser NOT cache the main page and DOES let it cache the external files (css/js/images).
I'm not sure if it's relevant, but the page uses an SSL connection and we use cookies to store the login sessions.
The code below is included in EACH document at the moment (so the main document, the css and the js).
Then the main document also has the following included:
How can I enable caching for the JS and CSS while making sure that the main PHP file is NOT being cached?
Thanks!
Sander
I have a website that requires login and I loading the pages takes too long (see image below).
Now the page roughly consists of:
- The actual page: training.xml.php
- An external stylesheet: allStyles.css.php
- An external javascript: allScripts.js.php
- Some images The main pages of the program (in this case training.xml.php) change very frequently, so these may NOT be cached.
The stylesheet and javascript are generated dynamically but remain the same throughout the session, so these may be cached.
I have not found a way that lets the browser NOT cache the main page and DOES let it cache the external files (css/js/images).
I'm not sure if it's relevant, but the page uses an SSL connection and we use cookies to store the login sessions.
The code below is included in EACH document at the moment (so the main document, the css and the js).
Code: Select all
// Assure that SSL is being used
if ($_SERVER["SSL_SERVER_S_DN_CN"] == "secure.xxx.net") {
//Session settings
ini_set("session.use_only_cookies", 1);
ini_set("session.save_path", "/home/xxx/sessions");
session_cache_limiter("must-revalidate");
session_start();
//Compress the page
ob_start("ob_gzhandler");
// ACTUAL CODE HERE
}
Code: Select all
header("Cache-Control: max-age=0, must-revalidate");
header("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
Thanks!
Sander