Sualdam
01-02-2004, 07:39 PM
Most people are probably aware of the problems with caching of files on the local computer. It was covered here:
http://www.webproworld.com/viewtopic.php?p=34155&highlight=nocache#34155
Well, I've been wrestling with a problem that that solution doesn't address - namely, my ISP (and at least one other in the UK) reduces the load on its servers by caching files on the proxy.
What this means is that you can't do a thing about a cached file loading until the proxy is flushed - and mine is doing it once every 24 hours at the moment. It has been driving me nuts because when I change a page/pages on any site I can't preview it unless I link directly to the file and use the old www.mydomain.com/foldername/filename.html?anumber to force a reload.
Now, I might be premature in blowing my trumpet as I'm waiting for the proxy to flush again tomorrow, but I came up with a solution using PHP, and it seems to work.
I wrote a small PHP file I called flush.php with the following:
<?php
# No-cache redirect
#
# Seed random number generator
#
srand (microtime() * 1000000);
#
$myNum = rand(1,999999);
$loc = "mainpage.php?".$myNum;
header("Location:$loc");
exit();
?>
I just call this from an anchor tag in the index file.
What this does is generate a random number between 1 and 999,999. It then appends this to the name of the page I want to load - forcing a refreshed page to load - and then forces the page to reload with this information.
It works under a cloak (one thing that I needed to do).
Once the index and PHP pages are cached, it doesn't matter any more because the random number will be generated by the cached PHP file no matter what. As long as the PHP file isn't changed, I don't have to wait for the proxy to flush any more.
I'm not sure if this will help anyone, but you never know ;)
http://www.webproworld.com/viewtopic.php?p=34155&highlight=nocache#34155
Well, I've been wrestling with a problem that that solution doesn't address - namely, my ISP (and at least one other in the UK) reduces the load on its servers by caching files on the proxy.
What this means is that you can't do a thing about a cached file loading until the proxy is flushed - and mine is doing it once every 24 hours at the moment. It has been driving me nuts because when I change a page/pages on any site I can't preview it unless I link directly to the file and use the old www.mydomain.com/foldername/filename.html?anumber to force a reload.
Now, I might be premature in blowing my trumpet as I'm waiting for the proxy to flush again tomorrow, but I came up with a solution using PHP, and it seems to work.
I wrote a small PHP file I called flush.php with the following:
<?php
# No-cache redirect
#
# Seed random number generator
#
srand (microtime() * 1000000);
#
$myNum = rand(1,999999);
$loc = "mainpage.php?".$myNum;
header("Location:$loc");
exit();
?>
I just call this from an anchor tag in the index file.
What this does is generate a random number between 1 and 999,999. It then appends this to the name of the page I want to load - forcing a refreshed page to load - and then forces the page to reload with this information.
It works under a cloak (one thing that I needed to do).
Once the index and PHP pages are cached, it doesn't matter any more because the random number will be generated by the cached PHP file no matter what. As long as the PHP file isn't changed, I don't have to wait for the proxy to flush any more.
I'm not sure if this will help anyone, but you never know ;)