473,790 Members | 3,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disable browser caching

Today I'm using
<html>
<head>
<meta http-equiv = "pragma" content = "no-cache">
</head>
This prevent the browser to cache the page. So each time I call the
following PHP script
<?php
echo date("d.m.Y") . " / " . date("H:i:s") . "<br>";
?>
the current time will be displayed.

However, if I call this PHP script over a proxy the time gets not updated.
I always have to press Shift + Reload.

A colleague told me that I have to program the no-caching-command somehow
within the http header.
How to do that and does this really solve my problem?

Stefan
Dec 10 '05 #1
5 5040
Stefan Mueller wrote:
<meta http-equiv = "pragma" content = "no-cache">


For starters, add cache-control and no-store. See
http://www.i18nguy.com/markup/metatags.html
http://developer.mozilla.org/en/docs...ox_1.5_caching

Using http://php.net/header you can send headers more reliably than
through the meta tag (especially when dealing with proxies).

--
E. Dronkert
Dec 10 '05 #2
<?php
// Date in the past
header("Expires : Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");
?>

Dec 10 '05 #3
*** Stefan Mueller escribió/wrote (Sat, 10 Dec 2005 20:22:50 +0100):
A colleague told me that I have to program the no-caching-command somehow
within the http header.


That's correct. As far as I know, proxies do not parse or even read the
HTML they serve. So HTML is not a good place to give directions :)
--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Dec 10 '05 #4
On 10/12/2005 20:15, Ewoud Dronkert wrote:

[snip]
See
http://www.i18nguy.com/markup/metatags.html


It should probably be expressed, more strongly than it has been, that
cache- (Expires, Cache-Control, etc.) and content-related (Content-Type,
Content-Language, etc.) directives should only be send via HTTP headers.
Clients will want to know this information /before/ they start parsing
the entity body, and others won't even look there.

Trying to substitute HTTP headers (any really, but these especially) for
META elements is very questionable.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Dec 10 '05 #5
I'm using
<?PHP
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');

and that works great.

Many thanks
Stefan
Dec 13 '05 #6

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

Similar topics

21
3267
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" http://www.tonymarston.co.uk/php-mysql/backbuttonblues.html -- Tony Marston http://www.tonymarston.net
1
418
by: Rune | last post by:
Hi I use MMIT to render XHTML pages. How do I disable client caching? I've tried the following commands: Response.CacheControl = "private"; Response.Cache.SetNoStore();
5
3139
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 click the button to open the popup again, then it opens with the values that were in it before the "save" was executed. I've determined that the problem is that IE is storing the page in it's local temporary internet files cache and isn't going to...
10
4401
by: Umut Tezduyar | last post by:
It seems, it is caching it. The following code is an example for it. How can avoid from this. override void OnLoad (sender and eventargs) { Control control = this.LoadControl (path); this.Controls.Add (control); // I change the content of the html of the control. TextReader reader = new StreamReader (path);
1
6021
by: Terry Olsen | last post by:
Is there any way to disable the client browser "Back" and "Forward" buttons while on my site? Or how would I go about knowing that a page hit is caused by a back/forward navigation? I have discovered that my web app is definately NOT Back/Forward safe. It's really messing with my SQL data bigtime. Thanks.
12
1655
by: Ken Varn | last post by:
Is there anyway within my web application that I can have all browser caching turned off for all aspx pages sent by my IIS server? I need to have all caching off in order for certain things to work properly, and I can't always rely on the user disabling their cache settings at the browser level. -- ----------------------------------- Ken Varn Senior Software Engineer Diebold Inc.
5
1067
by: Ufit | last post by:
I have image control with jpeg url on my asp.net web. That jpeg has the same name but changes Problem is that web is caching the old one even if its contents have changed. I cannot change the name of that pic but I must display current image. Please help with some good solution. Thanks Ufit
2
1706
by: Mantorok | last post by:
Hi Is there an easy way to disable ALL client-side caching for my entire web-site? Is there also an easy way to cause any "refreshes" and "back" actions to cause an automatic re-direct to my login page? Thanks Kev
4
2739
by: RedHair | last post by:
Development: Windows 2003 Production :Windows 2003 ASP.NET 2.0 + C# I want to disable the cache feature of all pages in dev but enable it in production environments. What's the solution? If uses cacheProfiles in web.config then I need to deploy different web.config files from dev to production sites.
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6770
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.