will a script in html's script tag with extension php be cached?

for example <script type="text/javascript" src="assets/scripts/somescript.php"></script> will my browser still cache this just by not setting this scripts headers meta tag cache to must-revalidate?


Some browsers are more agressive with default caching than others. However, there are cache control headers you can send to indicate when to reload the code.

header("Expires: " . date("r", time() + ( 60 * 60 * 24 * 7 * 1 ) ) ); // Expires in 1 week
header("Content-Type: application/x-javascript");

Is a code-snippet I've been known to use.

You can use more fancy stuff like If-Not-Modified headers and ETags, but Expire times are the only ones that eliminate extra server calls.

Need Your Help