473,387 Members | 1,585 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,387 software developers and data experts.

Prevent Safari from caching using header()

Hello PHP group

I'm trying to prevent Safari from caching pages (e.g. private pages),
so it is not possible to view them when hitting the back button.

I tried it as described on Apple's developer site:
http://developer.apple.com/internet/...q.html#anchor5

using

// PHP example - include at the top of your pages
<? 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, must-revalidate, max-
age=0"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>

However, this does not work.

Does anyone know a reliable solution?

Many thanks.
Aug 13 '08 #1
6 4694
Werschinger wrote:
Hello PHP group

I'm trying to prevent Safari from caching pages (e.g. private pages),
so it is not possible to view them when hitting the back button.

I tried it as described on Apple's developer site:
http://developer.apple.com/internet/...q.html#anchor5

using

// PHP example - include at the top of your pages
<? 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, must-revalidate, max-
age=0"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>

However, this does not work.

Does anyone know a reliable solution?

Many thanks.
You can't guarantee a page won't be cached - you can only recommend it.
Servers along the path as well as the browser can still cache the
information.

Try alt.html (hint - although you are using the header() function, the
problem is the headers themselves, not php).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 13 '08 #2
In our last episode,
<43**********************************@v57g2000hse. googlegroups.com>,
the lovely and talented Werschinger
broadcast on comp.lang.php:
Hello PHP group
I'm trying to prevent Safari from caching pages (e.g. private pages),
so it is not possible to view them when hitting the back button.
You cannot force this in HTML, and so you cannot force it in php,
because php is (or should be) HTML when it reaches the browser.
Depending upon what you mean by 'private pages,' this would seem to be a
browser question. In some browsers you must reduce memory and disc cache to
0 --- others have a more convenient check box for 'never use cached pages.'
Most modern browsers are fairly good about this; some older ones would
load new html but not reload linked css, which was a headache in
development. Consult your browser documentation or an appropriate browser
group.

--
Lars Eighner <http://larseighner.com/us****@larseighner.com
God is REAL, unless explicitly declared INTEGER.
Aug 13 '08 #3
Thanks for everybody's input.

I understand I cannot force it, but I've seen it work on other sites,
e.g. banking sites.

"Private" pages would be any pages you don't want others to see, like
your email inbox for instance.

I'm just looking for a solution for Safari in case of public or shared
computer usage. For IE6, 7 and Firefox, the mentioned solution works.

I've posted it in alt.html as suggested by Jerry. Maybe I should post
in a Safari group as well.
Aug 13 '08 #4
On Aug 13, 9:54*am, Werschinger <dinko.ve...@googlemail.comwrote:
Thanks for everybody's input.

I understand I cannot force it, but I've seen it work on other sites,
e.g. banking sites.
There's the best place to start, look at the page source of those
pages and see if you see anything obviously different.

Aug 13 '08 #5
How about forcing a session, then destroying it when they are done or
after a certain time limit.
Aug 13 '08 #6
..oO(la***@portcommodore.com)
>On Aug 13, 9:54*am, Werschinger <dinko.ve...@googlemail.comwrote:
>Thanks for everybody's input.

I understand I cannot force it, but I've seen it work on other sites,
e.g. banking sites.

There's the best place to start, look at the page source of those
pages and see if you see anything obviously different.
The HTTP response headers might be a better place to start.

Micha
Aug 13 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Cyrus D. | last post by:
Hi guys, Let's say I have a page that is primarily HTML but I added a few small parts that are PHP, for example a random banner. The page is in no way PHP driven, it just has some some random...
3
by: Santhi | last post by:
Hi, I wish to avoid caching asp pages at the user end . Currently I have declared Response.Expires=0 at the top of my asp page. I have also used the following meta tags to prevent client side...
14
by: Ludwig77 | last post by:
I read that there are some tags that can be entered in a web page's meta tags in order to prevent web bot searching and indexing of the web page for search engines. What is the tagging that I...
4
by: Laphan | last post by:
Hi All I know the first thing that some might say is that I shouldn't be using in frames in web sites, but they are listed as being part of the HTML 4.0 standard. I am trying to do my web...
10
by: Behzad | last post by:
Hi all I'am ASP programmer and I have built a site that users can upload and download files.All things store in a DB and everytime someone enters a page,the application requery the Db and shows...
5
by: R. Ian Lee | last post by:
I have an ASP.NET page that spawns a popup window using javascript's window.open. This works fine. It pops up, you enter some data, press save and everything saves as it should. But, if you...
0
by: Frankie | last post by:
When I want to prevent a page from being cached, I have been using the following directive: <%@ OutputCache Location="none" %> I have also seen a few other methods recommended to prevent page...
1
by: intuna | last post by:
I've seen a screen shot of my header graphic in Safari. (don't have Safari) I'm coding using Firefox and IE. In those browsers the behavior is consistent. I have two floated graphics, one...
12
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I'm using ASP.Net with an UpdatePanel. When the screen is exercised via a Web Test, the Web Test shows that the AJAX scripts are downloaded for every partial post back. My impression was that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.