Here is how to prevent caching of your javascript files or images or any other files of your website by the browser by using PHP. Just make sure that the below source code is at the very beginning of your php script before any content is written out to the browser. Make sure that there is not even a blank space before the start of this php snippet as that would cause your script to fail since headers in the code below cannot be sent after any data is sent to the browser.

<?php
//Content type is set to javascript, you can set it to any other type like images, xml, html etc
header('Content-type: application/javascript');
// Ask browser not to cache this file and always get the latest version from the server
header("Cache-Control: no-cache, must-revalidate");
// Set some date in the past as expiry date which means this file is always expired
header("Expires: Sat, 15 Jul 2000 05:00:00 GMT");
//Now read the actual file from disk and send it to the browser
readfile("script.js");
?>

SocialTwist Tell-a-Friend