Can someone explain Google Chrome in-memory cache?

前端 未结 1 1056
刺人心
刺人心 2021-02-12 05:48

According to this API doc, which is the only source I\'ve found which describes the in-memory cache:

Chrome employs two caches — an on-disk cache and a ve

1条回答
  •  忘了有多久
    2021-02-12 06:23

    In your case I think that your problem is with the long term cache instead the in-memory cache. In the resource waterfall several requests can be marked as cached. There are various manners to avoid that if you want:

    • Instead of normal reloading (F5) press CTRL+F5. That will reload all the resources, I usually press CTRL+F5 several times although one time must be suficient.
    • If you need that your page reload some specific resources from server each time any user visit you then you can use some of this techniques:
      • The most elegant: configure your server to return cache policies in the HTTP headers https://developer.mozilla.org/es/docs/Web/HTTP/Headers/Cache-Control
      • Add to your request a changing get parameter different each time, for example use milliseconds. For example: https://www.gravatar.com/avatar/c6252fcbc3ce5fc144c11dedd75bce29?_=1501147200802 where 1501147200802 is different for each reload. This will confuse cache so resource will be loaded from server each time you request it.

    Remember to apply these rules only for the resources that you really need to. Otherwise your webserver will be overloaded with innecesary requests.

    As stated in the document mentioned: in-memory cache does not apply to different page renderings even for the same url and in the same tab (in-memory cache is attached to the lifetime of a render process), so I think that does not apply for your case. Rendering cycle ends each time the page is displayed and a different one starts if rendered again. For example: when a image is loaded for the first time appears in the waterfall, but no for later requests on the same page.

    0 讨论(0)
提交回复
热议问题