Detecting browser cache by jQuery

后端 未结 3 1838
粉色の甜心
粉色の甜心 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:27

    Serve the page server-written timestamp value var origin = <%=someTimeStamp %>;, read it and compare against a JavaScript generated value representing the current time.

    Note: The client timestamp and the server timestamp would be different because there are chances the client system time is wrong and also the server and the client systems may not be from the same time zone. This has to be taken care.

提交回复
热议问题