Forum Moderators: coopster
Since each user has different config settings on my service, they must all identify themselves with an ID, for example, user John Doe must include this piece of code in his site:
<script src="http://blabla.com/script.php?id=384" type="text/javascript"></script>
That way the javascript that will get printed will use his own settings. What i need to do now, is to reduce my server's requests by properly caching the data. A friend told me to use this in the top of script.php:
header("Cache-Control: must-revalidate");
$offset = 60*60*24*7;
$ExpStr = "Expires: ".gmdate("D, d M Y H:i:s",time() + $offset)." GMT";
header($ExpStr);
header('Content-Type: application/x-javascript');
...
That way if a user comes back to John Doe's website, my server wont have to re-generate the whole code, and they will use the one in their cache.
Is that enough? Will it work? Thanks.
<?php
header("Expires: Mon, 26 Jul 1997 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");
?>