Detecting browser cache by jQuery

后端 未结 3 1881
粉色の甜心
粉色の甜心 2021-01-12 01:20

Is there a jQuery approach to detect whether a page is loaded from the browser cache OR it has been received from the server by HTTP request?

3条回答
  •  佛祖请我去吃肉
    2021-01-12 02:08

    The following article should answer your question:

    Detecting when a page is loaded from the browser cache.

    The concept of the above article is that at every request you set the cookie from the server side and check the cookie using JavaScript (or jQuery). if the cookie matches that of the previously requested page, then it is a cached page. If it doesn't, it is a fresh page.

    Hope that helps.

提交回复
热议问题