views:

24

answers:

2

If I use GET parameters to change my .php external javascript file to load different content based on the page non of the browsers are going to cache that file right? they will treat global_js.php?page=foo and global_js.php?page=bar as if they had different names and load the content again right? or should I include something in my header to do that?

UPDATE: Different get params are sent to the file and it will load different content. did I take a bad approach? my css looks like this:

<link rel="stylesheet" type="text/css" href="./CSS/css_global.php?load={$pagecat}&load_mootools={$load_mootools}&load_jquery={$load_jquery}&css_extra={$css_extra}&version={$xx_version}_{$css_extra}">

If I put each of my few external files in a separate file event though there will be multiple http requests most users don't activate a non-cache behavior on their browsers like us developers and they will cache the files resulting in a faster user experience but now with the different combination available on my CSS it will never be cached because each page is slightly different in the get parameters it sends the CSS file.

A: 

You may want to try this BEFORE any output from your .php file Javascript is loading.

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
B00MER
A: 

That's right, the browser will treat them as different files.

I won't recommend using B00MER approach if you DO want the files to be cached individually.

Once the files has been cached individually, you can force a cache update by appending a version parameter to the file, so every time you update the application (the version changes) the caches will be regenerated.

app.js?module=account&version=1.0_RC2_2010-09-28
xmarcos
but it's not just updating different get params are sent to the file and it will load different content. did I take a bad approach. cause today I thought to myself... If I put each of my few external files in a seperate file event though there will be multiple http requests most users don't activate a non-cache behaviour on their browsers like us developers and they will cache the files resulting in a faster user experience but now with the different combination available on my CSS it will never be cached because each page is slightly different in the get parameters it sends the CSS file.
Neo