使得缓存的内容,如果-Modified头? [英] Invalidating cached content, If-Modified Headers?

查看:146
本文介绍了使得缓存的内容,如果-Modified头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个特殊的问题:

PHP SCRIPT:

// checks If-Modified-Since header (if nothing has changed)
// Sends HTTP/1.0 304 Not Modified
// Sends Cache-control: public, must-revalidate
// exits

// if NO If-Modified-Since or something has changed
// builds content
// Sends Last-Modified: [DATE TIME]
// Sends Cache-control: public, must-revalidate
// exits

我使用jQuery AJAX来尝试刷新点播内容,我试图通过改变这样做了If-Modified-由于在过去的日期时间标题,使用beforeSend参数。

I am using jQuery AJAX to attempt to refresh the content on demand, I am trying to do this by altering the If-Modified-Since header with a DATE TIME in the past, using the "beforeSend" param.

这是目前发生了什么:

  1. 在请求时,200与新鲜的内容确定响应
  2. 在后续的请求得到了304响应,并从缓存器拉
  3. 在内容发生在服务器上
  4. 的请求与修改的If-Modified-Since头(无URL字符串改变)制成,200与新鲜的内容确定响应
  5. 在后续的请求(不改变的If-Modified-Since头)似乎检索步骤#1
  6. 的旧内容

我想在IM pression即时消息,在步骤4中,在浏览器的内容应该被刷新,我想什么?

I guess im under the impression that at step #4, the browsers content should have been refreshed, what am i missing?

我安装一个小测试,所以你可以尝试一下,看看我的意思是: http://tweetplenty.com /test/test2.php ...使用FF和Firebug的,如果你能为即时通讯使用的console.log()...这里是操作顺序:

I setup a little test so you can try and see what i mean: http://tweetplenty.com/test/test2.php ... use FF and firebug if you can as im using console.log() ... here is the order of operations:

  1. 到正常的链接会做的请求 http://tweetplenty.com/test /test.php 的无需修改如果改性-自...采用正常的链路应该返回304(它应该返回200行每60秒)的后续请求

  1. the "normal" link will do a request to http://tweetplenty.com/test/test.php without modifying if-modified-since ... subsequent requests using the "normal" link should return a 304 (it should return 200 OK every 60 seconds)

在如果 - 修改 - 自链接会做一个请求的http:// tweetplenty .COM /测试/ test.php的的改良如果 - 修改 - 自标头,浏览器将返回新的内容。

the "if-modified-since" link will do a request to http://tweetplenty.com/test/test.php WITH modified if-modified-since header, the browser will return new content.

单击正常了,在这一点上返回previously缓存的数据,我认为它应该点击后刷新数据的如果 - 修改 - 自链接。

clicking "normal" again at this point returns the previously cached data, I would think that it should have refreshed the data after clicking the "if-modified-since" link.

如果你想在这里签测试脚本本身你去: http://tweetplenty.com/test /test.zip

If you want to checkout the test scripts themselves here you go: http://tweetplenty.com/test/test.zip

推荐答案

我想你想修改进来的所有请求头检查出的此页面

I think you want to modify the headers on all requests coming in. Check out example #2 on this page.

这篇关于使得缓存的内容,如果-Modified头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆