Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-02-2004, 08:39 PM
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Posts: 1,087
Sualdam RepRank 0
Default An Alternative Way to Avoid Caching

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...=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 http://www.mydomain.com/foldername/f...e.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:

Code:
<?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 ;)
__________________
Sualdam
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0