Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
854 views
in Technique[技术] by (71.8m points)

http - Best way to disable client caching

I'm using a simple servlet filter that forces the browser to skip caching for some server resources:

    Cache-Control: private
    Pragma: 

This works fine in Internet Explorer but it doesn't works well with Firefox 3.0.10. I ended to write this code:

    Cache-Control: no-cache, no-store, must-revalidate, max-age=-1
    Pragma: no-cache, no-store
    Expires: -1 // -1 is the unix time, the client receives a date in 1969 :)
    Last-Modified: -1 // ditto

this forces firefox to cache nothing. What about other browsers? What about best practices on no caching headers that works on major browsers?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Drupal 6 does this (which works in every browser known by me):

  • Expires: Sun, 19 Nov 1978 05:00:00 GMT
  • Last-Modified: Fri, 12 Jun 2009 08:01:46 GMT (the actual modification date)
  • Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0

No pragma header in this instance. I'm not sure why your example doesn't work, it might be the negative timestamps, this works on ~250.000 Drupal sites :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...