OLD | NEW |
1 <?php | 1 <?php |
2 // Force the browser to cache this script. update() should always bypass this | 2 if(!isset($_COOKIE['mode'])) |
3 // cache and fetch a new version. | 3 $mode = 'init'; // Set mode to 'init' for initial fetch. |
4 header('Cache-Control: max-age=86400'); | 4 else |
| 5 $mode = $_COOKIE['mode']; // $_COOKIE['mode'] is either 'normal' or 'error'. |
5 | 6 |
| 7 // no-cache itself to ensure the user agent finds a new version for each update. |
| 8 header("Cache-Control: no-cache, must-revalidate"); |
| 9 header("Pragma: no-cache"); |
| 10 |
| 11 if ($mode == 'init') { |
| 12 // Set a normal mimetype. |
| 13 // Set cookie value to 'normal' so the next fetch will work in 'normal' mode. |
| 14 header('Content-Type:application/javascript'); |
| 15 setcookie('mode', 'normal'); |
| 16 } else if ($mode == 'normal') { |
| 17 // Set a normal mimetype. |
| 18 // Set cookie value to 'error' so the next fetch will work in 'error' mode. |
| 19 header('Content-Type:application/javascript'); |
| 20 setcookie('mode', 'error'); |
| 21 } else if ($mode == 'error') { |
| 22 // Set a disallowed mimetype. |
| 23 // Unset and delete cookie to clean up the test setting. |
| 24 header('Content-Type:text/html'); |
| 25 unset($_COOKIE['mode']); |
| 26 setcookie('mode', '', time() - 3600); |
| 27 } |
6 // Return a different script for each access. | 28 // Return a different script for each access. |
7 header('Content-Type:application/javascript'); | 29 echo '// ' . microtime(); |
8 echo '// ' . microtime() | |
9 ?> | 30 ?> |
OLD | NEW |