views:

250

answers:

3

I am trying to prevent If-modified request from client to server but I am failing. I think that I am missing something so I am attaching the HTTP communication of the two requests. I would expect that the second request will not be issued:

GET XXXXX/js/Is.js HTTP/1.1
Accept: */*
Referer: http://XXXXX/XXXXX/
Accept-Language: he
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Hewlett-Packard; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Host: xxxxxxxx:8080
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=XXXXXX



HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: public,max-age=860000
Expires: Sun, 3 Jan 2010 00:00:00 GMT
ETAG: W/"1634-1260925588406"
Last-Modified: Wed, 16 Dec 2009 01:06:28 GMT
Content-Encoding: gzip
Content-Type: text/javascript
Content-Length: 412
Date: Sun, 27 Dec 2009 07:25:52 GMT




GET /XXXXXXXX/Is.js HTTP/1.1
Accept: */*
Referer: http://XXXXXXXXX/XXXXXXX/servlet/Main
Accept-Language: he
UA-CPU: x86
Accept-Encoding: gzip, deflate
If-Modified-Since: Wed, 16 Dec 2009 01:06:28 GMT
If-None-Match: W/"1634-1260925588406"
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Hewlett-Packard; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Host: xxxxxx:8080
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=XXXXXX; 

HTTP/1.1 304 Not Modified
Server: Apache-Coyote/1.1
Pragma: No-cache
Cache-Control: public,max-age=860000
Expires: Sun, 3 Jan 2010 00:00:00 GMT
ETAG: W/"1634-1260925588406"
Date: Sun, 27 Dec 2009 07:34:33 GMT
A: 

You're sending Pragma: No-cache in your first response. That prevents Firefox from caching.

apphacker
Thanks, I tried to change it to Pragma: cache but it did not help.I do not understand why the browser is issuning a Pragma: no-cache on the request
lifey
+1  A: 

The Pragma: no-cache in the second request indicates that it happened as a result of a page refresh. A 304 is a correct response in that case. If you want to force a re-read, then you should use control-refresh.

RickNZ
Also, keep in mind that the Pragma: no-cache will be sent automatically if you're navigating to the target page by way of a META REFRESH.
EricLaw -MSFT-
I do not want to force reread quite the contrary. I was not issuing a page refresh. I was navigating to a blank page and then going back.
lifey
Can you eliminate the `Pragma` header from the response? Also, technically (according to the HTTP RFC), there's supposed to be a space between the comma in the Cache-Control header and the second field. It probably won't make a difference, but it might. It looks like you're using IE7. Is that correct? How were you navigating to the blank page and back? With an `<a>` tag and the browser's back button? Or with script? Or a redirect? Or a `<meta>` tag?
RickNZ
Thanks,Yes I am using IE7 I was navigating to about:blankand then I have navigated to the page back I will try to eliminate the pragma
lifey
Well it did not solve the problem, I don't get it.....Maybe it is related somehow to the html?First response header: HTTP/1.1 200 OKServer: Apache-Coyote/1.1Expires: Thu, 01 Jan 2020 02:00:00 ISTCache-Control: publicLast-Modified: Sun, 27 Dec 2009 12:37:43 GMTETag: W/"1634-1261917463046"Content-Type: text/javascriptContent-Length: 1634Date: Mon, 28 Dec 2009 12:19:17 GMTsecond requestHTTP/1.1 304 Not ModifiedServer: Apache-Coyote/1.1Expires: Thu, 01 Jan 2020 02:00:00 ISTCache-Control: publicLast-Modified: Sun, 27 Dec 2009 12:37:43 GMTDate: Mon, 28 Dec 2009 12:20:10 GMT
lifey
"IST" as a time zone on Expires isn't legal; it should be GMT. Also, the max-age section of Cache-Control is now missing. Expires is actually semi-deprecated in favor of max-age for HTTP 1.1.
RickNZ
Thanks for all your help :-) I have changed it but still this awful 304 :-(... Am I missing something ? may it be related to the weak etag?HTTP/1.1 200 OKServer: Apache-Coyote/1.1Expires: 01 Jan 2020 02:00:00 GMTCache-Control: public,max-age=860000Last-Modified: Sun, 27 Dec 2009 12:37:43 GMTETag: W/"1634-1261917463046"Content-Type: text/javascriptContent-Length: 1634Date: Mon, 28 Dec 2009 13:24:33 GMT
lifey
It looks like it must be related to the `Proxy: no-cache` in the request headers; that shouldn't be there for a "regular" request, such as from clicking on a link or hitting the Back button in the browser. The usual cause is either hitting the Refresh button in the browser, or a meta refresh tag on the page. IIRC, there are other meta tags on the page that can cause it, too (such as no-cache). Do you have any meta tags on the page?
RickNZ
A: 

I think that I have found the problem.... I knew that I was missing something The first document loaded is doing redirect with :

 <meta HTTP-EQUIV="Refresh" CONTENT="1; URL=/XXXXX">

Thanks for all your help ....

lifey