Chrome doesn't send “If-Modified-Since”

前端 未结 5 2115
长发绾君心
长发绾君心 2021-02-15 19:35

I want browsers to always add (except first time) \"If-Modified-Since\" request header to avoid unnecessary traffic.

Response headers are:

Accept-Ranges:         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 20:11

    I've noticed almost the same behaviour and my findings are:

    • First of all the 200 status indicator in chrome is not the whole truth, you need to look at the "Size Content" column as well. If this says "(from cache)" the resource was take directly from cache without even asking if it was modified.

    • This caching behaviour of resources that lack any indication of expires or max-age seems to apply when requesting static files that have a last-modified header. I've noted that chrome (ver. 22):

      1. Asks for the file the first time (obviously since it is not in cache).
      2. Asks if it is modified the second time (since it is in cache but has no indication of freshness).
      3. Uses it directly the third time and then on (even if it is a new browser session).
    • I'm a bit puzzled by this behaviour but it is fairly reasonable, if it is static, was modified a long time ago, and hasn't changed since last check you could assume that it is going to be valid for a while longer (don't know how they calculate it though).

提交回复
热议问题