jiajianrong
jiajianrong

Reputation: 928

Why the expired css style still cached rather than requesting from server?

I visit this page twice by clicking enter key in address bar in chrome. The css file seems expired: cache-control max-age is 5 days, but last-modified is 5 days ago(I'm in China and now the time is Oct. 24 2016 12:16 PM). Thanks in advance.

enter image description here

The whole request headers:

Accept:text/css,*/*;q=0.1
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8
Host:c.58cdn.com.cn
Proxy-Connection:keep-alive
Referer:http://m.58.com/bj/zufang/?58ihm=m_house_index_zufang&58cid=1&PGTID=0d200001-0000-15fd-aae2-e605031f9c08&ClickID=1
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1

And the whole reponse headers:

Age:69061
Cache-Control:max-age=432000
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/css
Date:Wed, 23 Nov 2016 08:43:18 GMT
Last-Modified:Fri, 18 Nov 2016 08:38:39 GMT
Transfer-Encoding:chunked
X-Cache:HIT from www.matocloud.com

Upvotes: 1

Views: 74

Answers (3)

jiajianrong
jiajianrong

Reputation: 928

Now I know why the last-modified doesn't work - cache-control has the higher priority over last-modified.

So if I visit the css earlier in 5 days, browser will always load it from cache, which is exactly cache-control 's purpose.

Upvotes: 0

madz
madz

Reputation: 1873

I think it might be because of the if-modified-since effect. Browser sends request to the cache server and cache requests with if-modified-since and server sends OK so the cache directly sends with hit xcache header

Upvotes: 0

Dan Zheng
Dan Zheng

Reputation: 1673

This is because of the GMT time zone of the Last-Modified field. This is different from your local timezone.

The Last-Modified field has the time 08:38:39 GMT. However, the current time is only 04:22:54 GMT.

You can here the current GMT time here: http://time.is/GMT

EDIT: The Date field in your response header is not accurate for some reason. The time has not yet reached 08:43:18 GMT.

Upvotes: 1

Related Questions