LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-14-2004, 06:01 AM   #1
w0000422
Member
 
Registered: Dec 2003
Distribution: redhat linux 9.0
Posts: 60

Rep: Reputation: 15
How to prevent caching from web browser?


hello, i need to refresh the web page everytime the user has reenter the existing URL or clicking on back button...one way to solve this problem is prevent caching from web browser, right.

i had tried the meta type method but this method seem like not very effective for IE.
<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">


then, i tried to use php method to disable the caching feature but come out an error like this:
Warning: Cannot modify header information - headers already sent by (output started at /home/james/public_html/investment/investment.php:1) in /home/james/public_html/investment/investment.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/james/public_html/investment/investment.php:1) in /home/james/public_html/investment/investment.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/james/public_html/investment/investment.php:1) in /home/james/public_html/investment/investment.php on line 1

Warning: Cannot modify header information - headers already sent by (output started at /home/james/public_html/investment/investment.php:1) in /home/james/public_html/investment/investment.php on line 1



<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>

does anyone know what i had done wrong?
 
Old 01-14-2004, 06:45 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,295

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Hi

You're doing it right, but the "header" stuff has to be before any other output of the script. The error messages suggests it's in line 1 of investment.php - maybe you're doing this:

<html>
<?php
header...
?>

Change it to:
<?php
header...
?>
<html>
...

and it should work.
 
Old 01-14-2004, 07:16 PM   #3
w0000422
Member
 
Registered: Dec 2003
Distribution: redhat linux 9.0
Posts: 60

Original Poster
Rep: Reputation: 15
i had used the method u mentioned but i just won't work...
 
Old 01-14-2004, 11:24 PM   #4
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
your php script must be the very first thing in the file (like Guttorm mentioned). That should work unless you forgot something else. Also adding a "Content-type" header before all other headers would be nice.

Also pragma: no cache is becoming depricated, but i can't think of any other method at the moment.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
browser plugin for Konqueror web browser (linspire) Tracianddwayne Linux - Newbie 1 01-01-2005 03:15 PM
public web browser aka web kiosk xmnemonic Linux - Software 6 06-14-2004 04:20 PM
Caching of web contents using redhat 9 kingwhiteman Linux - Newbie 0 02-13-2004 08:04 AM
How to prevent them from caching my images? vous Programming 5 11-15-2003 09:49 AM
Info on setting up internal web/dns caching server. l0f33t Linux - Networking 1 05-25-2003 10:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration