Page 1 of 1 [ 8 posts ] 

StevieC
Veteran
Veteran

User avatar

Joined: 30 Dec 2009
Age: 35
Gender: Male
Posts: 649
Location: Cupboard under the Stairs

04 Oct 2011, 9:11 pm

having some problems with webpages caching, ie i dont want them to

i have designed the webpage with iWeb '09 v3.0.4
and have inserted this into my head tags:

<meta http-equiv="expires" content="-1" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta name="revisit-after" content="0 days" />

and STILL, the page caches - i thought just in Chrome at first, but now also firefox.


1) do i have to set my server up for caching somehow? (i'm serving .html files, altho am capable of PHP & ASP)

2) do i need head tags not only at the start of the document, but at the end also?




the fact that it caches causes obvious problems when updating the page - so someone that has visited before will not see the changes.


_________________
I'm a PC and Ubuntu was my idea.


My RSS feed:
www.steviecandtheplacetobe.net/rss.xml


StevieC
Veteran
Veteran

User avatar

Joined: 30 Dec 2009
Age: 35
Gender: Male
Posts: 649
Location: Cupboard under the Stairs

09 Oct 2011, 10:39 pm

as an update:

ive done some digging and it appears its to do with HTTP headers - ie because im with GoDaddy, i cant owrk out how to change them, and because im working with Apple iWeb, i can only output .html files 8O


on the non iweb part of my site, where i have coded manually with textedit/ms notepad/GEdit/etc each page is .asp, and by using firefoxes http header plugin, i can see that the .asp pages have an http header that sets cache control to private AND max-age-0 and sets an expiry cookie, while in the html side only has max-age-0 cache control ERGO, any changes i make are displayed immediately, whereas with iweb, even with ALL my html cache control cack, i have to do a manual refrsh to see the changes. so just by having a microsoft asp file seems to solve th problem.


so basically, the Microsoft IIS side of things is automatically adding some kind of response header to the asp files, something that html files cannot so as they are client side only, not server side.


however, even manually renaming the iweb files to .asp still makes the navbar somehow see .html, and iv been right thru the javascripts and cant see anythign relating to file extensions. so for the moment, its not godaddy at fault, its apple. and microsoft seems to save the day. weird....


_________________
I'm a PC and Ubuntu was my idea.


My RSS feed:
www.steviecandtheplacetobe.net/rss.xml


NeantHumain
Veteran
Veteran

User avatar

Joined: 24 Jun 2004
Age: 45
Gender: Male
Posts: 4,837
Location: St. Louis, Missouri

10 Oct 2011, 9:01 am

You probably want to set the ASP server-side script (usually written in VBScript) to spit out "NO CACHE" HTTP headers. PHP could do the same thing.

Let me Google that for you.



NeantHumain
Veteran
Veteran

User avatar

Joined: 24 Jun 2004
Age: 45
Gender: Male
Posts: 4,837
Location: St. Louis, Missouri

10 Oct 2011, 9:10 am

Actually, for static HTML (i.e., HTML not generated from some server-side script), you shouldn't have to bother with any no-cache headers at all. Your browser should be smart enough to recognize that the content has changed.



mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 35
Gender: Male
Posts: 538
Location: Sacramento

10 Oct 2011, 1:52 pm

You need to configure IIS to add the no-cache header to static content.

Add this in you web.config:

Code:
<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="DisableCache" />
      </staticContent>
   </system.webServer>
</configuration>



StevieC
Veteran
Veteran

User avatar

Joined: 30 Dec 2009
Age: 35
Gender: Male
Posts: 649
Location: Cupboard under the Stairs

10 Oct 2011, 9:38 pm

mcg wrote:
You need to configure IIS to add the no-cache header to static content.

Add this in you web.config:
Code:
<configuration>
   <system.webServer>
      <staticContent>
         <clientCache cacheControlMode="DisableCache" />
      </staticContent>
   </system.webServer>
</configuration>


my hosting ISP doesnt allow me to access my htaccess or web.config 8O


@NeantHumain: yeah, no offense but how do i add ASP headers to HTML? HTML is client side only. iv tried FF, Opera, Chrome and Safari and all have the same problem - ie they cache anyway despite there being HTML META tags telling them not to.....

my point is that for the ASP portion of the site, i havent put in ASP headers, but Microsoft seems to put one in anyway: the private cache directive, which is missing from the PHP and HTML pages (when i view in firefox with Live HTTP headers)



most sites i visit: facebook, mugglenet, have NO client side meta tags - but all have expiry parameters (set by the server) ....







i have concluded (but cannot prove) that my page is being cached in a proxy ie AOLs one, or whatever, which would pay attention to ASP based HHTP headers, but would also ignore HTML based META-Equiv tags....


_________________
I'm a PC and Ubuntu was my idea.


My RSS feed:
www.steviecandtheplacetobe.net/rss.xml


mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 35
Gender: Male
Posts: 538
Location: Sacramento

11 Oct 2011, 12:02 am

StevieC wrote:
my hosting ISP doesnt allow me to access my htaccess or web.config 8O

That's inconvenient. You might try calling them and asking if there is anyway you can get their servers to add the cache-control header to your responses.


StevieC wrote:
@NeantHumain: yeah, no offense but how do i add ASP headers to HTML? HTML is client side only. iv tried FF, Opera, Chrome and Safari and all have the same problem - ie they cache anyway despite there being HTML META tags telling them not to.....

my point is that for the ASP portion of the site, i havent put in ASP headers, but Microsoft seems to put one in anyway: the private cache directive, which is missing from the PHP and HTML pages (when i view in firefox with Live HTTP headers)
Well if your host supports ASP then converting your static HTML pages to ASP should be pretty simple (I have no experience with classic ASP, but with ASP.NET is as simple as renaming your file and adding a few lines at the beginning).



mcg
Veteran
Veteran

User avatar

Joined: 26 Jan 2010
Age: 35
Gender: Male
Posts: 538
Location: Sacramento

11 Oct 2011, 12:10 am

By the way, if there really is no way to get your host to send the cache-control header, then there are some creative options you can use. If you use an iframe in your page and use javascript to append a random query string to the URI of your content, then you can defeat caching by browsers and routers. Basically, make your page nothing but a simple iframe with a script to point the iframe to your real content + a random query string, i.e. "myStaticContent.html?randomField=randomStuff". The server will ignore the query string but browsers and routers will treat it as a request to a new resource.