|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Browser Cache with php
My index.php page contains latest news taken from a MySql database. The problem I get is as some browsers save the last visited page view, when visitors return any news added doesn't show unless they refresh the page. What is the best way to overcome this problem so a manual refresh is not needed.
Thanks and hope someone can help. |
|
#2
|
|||
|
|||
|
You need to tell browsers not to cache your data with the following http headers
PHP Code:
(from www.php.net/header) HTH, Hadley |
|
#3
|
|||
|
|||
|
if hadley's example does not work try this:
PHP Code:
I had all sorts of problems trying to get no-cache to work until I set both expires and last-modified with getdate(). |
|
#4
|
|||
|
|||
|
Thanks for your help guys. I actually cheated a bit and viewed the source code of these forums home page and a solution was there staring me in the face.
<!-- no cache headers --> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="no-cache"> <meta http-equiv="Expires" content="-1"> <meta http-equiv="Cache-Control" content="no-cache"> <!-- end no cache headers --> Very similar to your suggestions and I will in fact try them both and add them to my script reference library i am building for personal reference. Again thanks. |
|
#5
|
|||
|
|||
|
It's slightly better to send the no-cache http headers (using the header function) because any proxies along the way will also heed your suggestions. Most proxy caches don't actually parse the html so won't see the http-equiv metadata.
In any case, you only need one or the other, not both. Hadley |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Browser Cache with php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|