473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Browser cache causing problem viewing php generated dynamic data

2
I have a PHP 4.4.7, MySql 5.0 and I.E. 7. My PHP queries the database and renders the info into html forms. Submitting the forms manipulates the data.

Now, the problem is that the browsers are caching the dynamic pages. Once the data is updated, returning to the original viewing page shows the old data until you hit refresh.

I know I can have my users adjust their internet file settings to "Check for newer versions of stored pages" to stop this behavior. I don't want to have to rely on users to make browser setting changes. They are challenged enough as it is.

Is there a way I can force the browsers to refresh at each viewing?

I've already tried placing an outdated meta tag in the headers to make the browser think the pages are too old:
Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="EXPIRES" CONTENT="TUES, 31 DEC 1996 12:00:00 GMT"> 
That doesn't seem to work.

Tom
Apr 23 '08 #1
3 1965
drhowarddrfine
7,435 Expert 4TB
Browsers don't pay much attention to that anymore. The best method is setting it in the http headers. I don't know how to do that in PHP.
Apr 23 '08 #2
Tom
2
I found it after much gnashing of teeth and many google searches. It was right in php.net. I guess I just wasn't searching with the right phrases. And I apologize that this is really a PHP issue and not an HTML question.

To manually force PHP web pages to refresh when visited because of dynamic content, you can use the header function:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  3. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  4. ?>
There are a number of restrictions about the command's location in your script. You can read more at php.net
Apr 23 '08 #3
gits
5,390 Expert Mod 4TB
you could even use a unique additional querystring for the url that is requested ... so instead of requesting:

Expand|Select|Wrap|Line Numbers
  1. foo.php
just request:

Expand|Select|Wrap|Line Numbers
  1. foo.php?my_key=unique_value
where unique-value could be a timestamp added by javascript for example.

kind regards
Apr 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ralph Freshour | last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP? Thanks...
21
by: Tony Marston | last post by:
If the use of the browser's BACK button is interfering with the operation of your web application then take a look at this article entitle "Back Button Blues" ...
2
by: Ben | last post by:
Hi all, I have written a web server that listens for requests: class MyHandler(BaseHTTPRequestHandler): def do_GET(self): if (self.path)=='/': data=makeList() else:
2
by: Peter Row | last post by:
Hi, I have a site were the pages are dynamically generated on demand. These pages like any static html page may contain image tags and references to CSS files. All the images and CSS files...
1
by: Denise | last post by:
In my application, I am setting cookies used for other pages based on the current row selected. But when the user presses the 'back' button, the pageload event does not get called and the record...
3
by: PaulR | last post by:
Hi, I am trying to understand what invalidates Dynamic Packages in the Package Cache. By monitoring the Size of the Package Cache, it appears the following does 1. Performing a Runstats on...
21
by: nsimeonov | last post by:
Hello, Does anyone have any idea how Gmail does this? I have a web application and people complain sometimes about some problems and most of the time it turns out it's the browser's cache...
1
by: emer.kurbegovic | last post by:
Is it possible to cache dynamic images in client's browser the same way static images are cached? for example, i'd like to be able to cache this dynamic image: <img src=pic.axd?id=2the same way...
1
by: Randy | last post by:
I have an application with a datagrid and a button to export the grid to excel. For the most part this is working fine. Here's the export method: Private Sub btnExcel_Click(ByVal sender As...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.