Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-11-2004, 10:30 AM   #1 (permalink)
Kernel_Killer
Regular Contributor
 
Kernel_Killer's Avatar
 
Join Date: Feb 2003
Location: indisclosed
Posts: 210
Kernel_Killer is on a distinguished road
Ignoring Cache

I'm having a bit of trouble with people looking at one of my sites, and complaining about not seeing the recent changes of one of the pages. The problem is that their cache is still holding the page that was their previous to the update.

Is there a way to have it ignore the cache settings, or refresh everytime it's loaded?
Kernel_Killer is offline   Reply With Quote
Old 04-11-2004, 12:53 PM   #2 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Based on the <HTTP/1.1 specification>, if I'm reading this correctly, you can specify one or two <Cache-control> methods to handle this:

<Cache-control: "no-cache">

<Cache-control: "max-age=0">

Looks like there is also another directive - 'must-revalidate' that might be along the same lines...
bdl is offline   Reply With Quote
Old 04-11-2004, 10:02 PM   #3 (permalink)
Kernel_Killer
Regular Contributor
 
Kernel_Killer's Avatar
 
Join Date: Feb 2003
Location: indisclosed
Posts: 210
Kernel_Killer is on a distinguished road
Thanx bdl!

Looks like the web host doesn't have the required apache modules added. Oh well. Guess I will have to E-mail the admin, or force root privs.

Isn't there a way to auto-refresh with javascript? Just trying to think of other solutions since the best idea is nixed.
__________________
Network Synapse
Screaming Electron
Kernel_Killer is offline   Reply With Quote
Old 04-12-2004, 11:05 AM   #4 (permalink)
ender
Code Monkey
 
ender's Avatar
 
Join Date: Mar 2003
Location: Evansville, IN
Posts: 75
ender is on a distinguished road
Send a message via AIM to ender Send a message via Yahoo to ender
There is actually a built-in meta tag for html that will make it no-cache...here is the code (this works on all IE versions, and Netscape Navigator:

(In your <head> portion)
Code:
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
If you don't want that, I believe you can force them to refresh afte a second or so with the following code in the head portion of your page:

Code:
<meta http-equiv="Refresh" content="1; URL=http://...>
However, I don't know if that will do what you want with the caching problems, but it will refresh. And if you put a big enough time on there, it will keep refreshing. However, for a one-time deal, that's not the best solution.

If you really wanted to do javascript, the code is the following (in <script> tags of course )

Code:
function refresh_page() {
   window.location = window.location
}
...later in your body tag...
<body onload="setInterval('refresh_page();', 5000)">
Now please beware that the code above will be executed every 5 seconds, as once the page is loaded it will exectue the onload code again. So you might want to do some neat cookie stuff or server-side hidden form variables to make sure that you dont' refresh more than once or so. However, these are the two teqniques that I have come across

Hope this helps,
Ted Morse
__________________
while(1) fork();
ender is offline   Reply With Quote
Old 04-15-2004, 02:22 PM   #5 (permalink)
Kernel_Killer
Regular Contributor
 
Kernel_Killer's Avatar
 
Join Date: Feb 2003
Location: indisclosed
Posts: 210
Kernel_Killer is on a distinguished road
Thanx ender. Going to try out the pragma tags and get this issue out of the way.
Kernel_Killer is offline   Reply With Quote
Old 05-13-2004, 06:50 AM   #6 (permalink)
shamaan
Registered User
 
shamaan's Avatar
 
Join Date: May 2004
Location: Heart
Posts: 5
shamaan is on a distinguished road
Send a message via Yahoo to shamaan
I'm also having the same problem. and i used the scripts as pasted here. But it did not work for me. the counter on index.html goes on counting everytime I refresh the page. but the content or amendments made did not get refreshed. still showing the old content. Y?
shamaan is offline   Reply With Quote
Old 05-16-2004, 12:32 AM   #7 (permalink)
Kernel_Killer
Regular Contributor
 
Kernel_Killer's Avatar
 
Join Date: Feb 2003
Location: indisclosed
Posts: 210
Kernel_Killer is on a distinguished road
Here's what works for me:

Code:
<head>
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Expires" content="-1">
</head>
Kernel_Killer is offline   Reply With Quote
Old 05-25-2005, 04:55 AM   #8 (permalink)
sujith(ARS)
Registered User
 
Join Date: May 2005
Posts: 9
sujith(ARS) is on a distinguished road
Sir,
I'm a beginner in ASP.NET,C#.

I developed a site that displays an image; on every request the image needs to be modified. But in my case, 1st time image is loaded properly but after that the image is not refreshed with the new images; instead the browser displays the image from the cache. I tried the meta tag "Cache-Control", "Pragma",... but still its not working.
This is the code that I had written
+++++++++++
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="My.WebForm1" %>
<%
Response.Buffer = false ;
Response.CacheControl = "No-cache" ;
Response.Expires = -1 ;
Response.AddHeader ("Pragma", "no-cache") ;

%>
<!--Response.CacheControl = "private" ; -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>MyPage</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta http-equiv="imagetoolbar" content="no">

<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">

<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">


</HEAD>
<body bgColor="#235f91" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Image id="Image1" style="Z-INDEX: 116; LEFT: 323px; POSITION: absolute; TOP: 115px" runat="server"
ImageUrl="file:///E://images/map.gif"></asp:Image></form>


</body>
</HTML>
+++++++++++
Can u pls tell me where I went wrong?
Expecting your reply
Thanks in advance
Cheers
Sujith
sujith(ARS) is offline   Reply With Quote
Old 05-25-2005, 06:15 AM   #9 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Shouldn't
<META Http-Equiv="Expires" Content="0">
be
<META Http-Equiv="Expires" Content="-1">
Since 0 sets it to infinite.. ie. never expires..
Else I have no clue.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-25-2005, 08:12 AM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
on a side note, i am just curious about the word 'sir.' i see it alot so i was just wondering. is that something that is taught to english students? or is it just common to casually address people as sir in other parts of the country.

here in the u.s., it is probably more formal than not, like something you may see in a business letter as opposed to forums or casual conversation. another use may be just sarcasm for fun. this is in no way a flame, just something i think about when i read posts that always start with sir.
__________________
Mike
sde is offline   Reply With Quote
Old 05-25-2005, 08:49 AM   #11 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
hmm.. I've always learned adressing someone with Sir, is apropriate, if you are addressing someone who's been knighted or is of a higher order than you..
My assumption is, that noone attending CodeNewbie has been knighted yet, but you'll never know..

On another side note, I remember having read, the english(uk) 'sir' can be compared to the Germain word Herr, and in germany you address someone Herr, when they are older than you (20 years or more), the word Herr, can be compared with the danish word Hr. which is equivalent to the english(us) Mr. *)
So if we combine all this wordpuzzle, then what we end up with is that the phrase sir can be used, when addressing someone older or of a higher order than you, if we look at this through late night puffs, no pun intended. You could say that the respect shown in addressing the helping staff here with sir is a refference to the knowledge, that the questionere knows the staff members are wiser and on a higher level than their own technical skills.

Or I'm just shooting birds with cannons on this one...

*)In this comparison, the reference is to the word Herr and Hr. starting with a capital letter, not the herr/hr, which is used if you only know the last name of a person, as in hr. Rasmussen. I wouldn't know if the word Sir, has a counter part sir like that..
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-25-2005, 09:33 AM   #12 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
good information there. =) .. I was taking it as the eqivalent to Mr. here. I would use 'Sir' verbally when I used to do tech support and wanted to inturrupt a babbling customer.
Quote:
Sir, Sir, .. Sir please, .. you called me for help right?
__________________
Mike
sde is offline   Reply With Quote
Old 05-25-2005, 10:20 PM   #13 (permalink)
sujith(ARS)
Registered User
 
Join Date: May 2005
Posts: 9
sujith(ARS) is on a distinguished road
Sir,
Thanks for the help redhead.But the matter is i tried ,
<META Http-Equiv="Expires" Content="-1">
too,still its not working in the case of images.The image is still being cached.

sde,
I used the word "Sir" to show my respect to the wiser peoples in here.

Cheers,
Sujith
-----------------------------------------------------
"Give respect ,take respect
sujith(ARS) is offline   Reply With Quote
Old 05-26-2005, 12:07 AM   #14 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
Are you sure, it's not the webserver which is caching the images, and not the users browser?
Just a thought, I have no knowledge on how your image is changed, if it's a dynamic generated one from the server, then this shouldn't be the case, but I've seen coincidences where I was out of my head trying to changed and image, and found out it was the webserver caching the old one.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 05-26-2005, 11:48 PM   #15 (permalink)
sujith(ARS)
Registered User
 
Join Date: May 2005
Posts: 9
sujith(ARS) is on a distinguished road
redhead,
i cross checked the cache of browser ,and i found that the image is being cached at the users browser.Its confirmed since, if i change the setting of the users Browser to get the image on every visit to the page ,then the image is refreshed every time.,but i can't force the customer to do that, thats the reason i really need to know how it can be done using ASP

Cheers,
Sujith
-----------------------------------------------------
"Give respect ,take respect"
sujith(ARS) is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 01:56 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting