How to Clear Cache

This is a discussion on How to Clear Cache within the PHP Language forums, part of the PHP Programming Forums category; Hello Group, I have a php file which will list the pending task for each developer. If the developer changes ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-11-2005
Sure
 
Posts: n/a
Default How to Clear Cache

Hello Group,

I have a php file which will list the pending
task for each developer. If the developer
changes some thing it will update to database.
Once the user clicks the update button it shows
the another page and there will be button back to
list of pending task. It will again fetch from database.

At the second time if user update some other data. It giving
me the old data list also.

Anyone Pls suggest me how to clear the cache in PHP.

I used ClearStatCache() this is not working. And also I added

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="expires" CONTENT="0"> in my php file.
Reply With Quote
  #2 (permalink)  
Old 01-11-2005
Daniel Tryba
 
Posts: n/a
Default Re: How to Clear Cache

Sure <csuresh01@yahoo.com> wrote:
> At the second time if user update some other data. It giving
> me the old data list also.
>
> Anyone Pls suggest me how to clear the cache in PHP.


Don't try to fix the symptoms, fix the real problem. You simply can't
clear a cache in a browser.

> I used ClearStatCache() this is not working. And also I added
>
> <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
> <META HTTP-EQUIV="expires" CONTENT="0"> in my php file.


Don't use those silly equivs if you can use the real http headers.
Setting the expires header in the past should normally be enough.

You could send a correct last-modified header (which you have to store
somewhere (might already be in the database)) and check if a client
does a conditional request (if-not-modified-since IIRC).

You should take a look at chapter 13 and 14.9 of the HTTP 1.1 protocol
(rfc 2616) to find out how to control/prevent/hint caching.
Reply With Quote
  #3 (permalink)  
Old 01-11-2005
Erwin Moller
 
Posts: n/a
Default Re: How to Clear Cache

Sure wrote:

> Hello Group,
>
> I have a php file which will list the pending
> task for each developer. If the developer
> changes some thing it will update to database.
> Once the user clicks the update button it shows
> the another page and there will be button back to
> list of pending task. It will again fetch from database.
>
> At the second time if user update some other data. It giving
> me the old data list also.
>
> Anyone Pls suggest me how to clear the cache in PHP.
>
> I used ClearStatCache() this is not working. And also I added
>
> <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
> <META HTTP-EQUIV="expires" CONTENT="0"> in my php file.


Hi,

Caching can be a pain in the ... side?
:-)

You use:
<META HTTP-EQUIV="expires" CONTENT="0">
Why did you put 0 there?

Are you aware that "0" is an illegal value?

(Illegal values should mean: expire immediately)

Read this:
http://vancouver-webpages.com/META/metatags.detail.html

But that doesn't solve your problem, does it?

I can think of two solutions:

1) GOOD SOLUTION: Start reading a lot about caching and try to solve it by
sending a right set of header. You could start here:
http://vancouver-webpages.com/CacheNow/

2) Poor men solution (the one I use. :P)
Trick possible cachingmechanisms (in the browser or a proxyserver) by asking
for 'another' page by adding a little extra to the script.

Like this:

<form action="yourpage.php?dontcacheme=<?= time() ?>" >


By the way: I never experienced the problem you describe with forms, only
with hyperlinks. Not sure if that means anything...

Good luck!

Regards,
Erwin Moller
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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




All times are GMT +1. The time now is 09:44 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0