How to prevent Ajax/javascript result caching in browsers?

前端 未结 5 1799
遥遥无期
遥遥无期 2020-11-28 13:13

How to prevent browsers from caching Ajax results? I have and event triggered Ajax script the displays results only when the browsers data has been cleared.

Tes

5条回答
  •  无人及你
    2020-11-28 13:29

    The random URL works, but it's kind of a hack. HTTP has solutions built in that should work. Try using the solution indicated here. Basically, set the headers:

    "Pragma":            "no-cache",
    "Cache-Control":     "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
    "Expires":           0,
    "Last-Modified":     new Date(0), // January 1, 1970
    "If-Modified-Since": new Date(0)
    

提交回复
热议问题