Forum Moderators: coopster

Message Too Old, No Replies

problem in caching

         

Majid

12:48 pm on May 24, 2008 (gmt 0)

10+ Year Member



Hello,

I wrote a PHP program to run in my computer (I use this program as a application and in IE)

I have a huge problem and that is caching in browsers.
for example when I add a record , my program refresh the page but the new record don't listed so I should refresh the page with Ctrl+F5 to view new record.
what should I do ?
I use AJAX for this list of records and many of this program use JavaScript codes.

P.S: sorry for my bad English .

Regards,
Majid

[edited by: Majid at 12:50 pm (utc) on May 24, 2008]

JAB Creations

4:06 pm on May 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In some version(s) of Opera the browser would cache file with various HTTP queries (different queries mean different content of course) for a JavaScript onload file that is dynamically created by PHP.

Try using this at the very top of the file and it may helpful to you!

- John

<?php
//Set content-type and other headers to prevent cache:
// header('Content-type: application/javascript');
header('Expires: Tue, 22 May 1988 03:20:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, n0-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');