开发者

Client controlled cache expiry times, using stale results

How can I restrict the maximum age and/or staleness of a resource from the client?

Scenario

I have 2 different page开发者_StackOverflow中文版s, e.g. /Show and /Edit, both of these pages use ajax to query a list of items, eg /Items.

The /Show and /Edit have different constraints on how old (stale) the data is allowed to be, thus the server cannot clearly define the maximum age.


Attempt 1

Request:
GET /Items
Cache-Control: max-age=5, max-stale=0

Response:
Cache-Control: private, max-stale=2592000, max-age=60
Date: Thu, 15 Sep 2011 17:16:02 GMT

(wait 10 seconds)
GET /Items
Cache-Control: max-age=5, max-stale=0

Expected Result

Second response would come from server.

Actual Result

Response was served from cache.


Attempt 2

Request:
GET /Items
Cache-Control: max-stale=60

Response:
Cache-Control: private, max-stale=2592000, max-age=5
Date: Thu, 15 Sep 2011 17:16:02 GMT

(wait 10 seconds)
GET /Items
Cache-Control: max-stale=60

Expected Result

Second response would come from cache

Actual Result

Response was served from server.


I have also tried using other various combinations, and looked at min-fresh, none of which I have been able to get to work correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜