通过jQuery检测浏览器缓存 [英] Detecting browser cache by jQuery

查看:128
本文介绍了通过jQuery检测浏览器缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有 jQuery 方法来检测页面是从浏览器缓存加载还是通过HTTP请求从服务器收到?

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?

推荐答案

以下文章应该回答你的问题:

The following article should answer your question:

检测从浏览器加载页面的时间缓存。

上述文章的概念是,每次请求都要从服务器端设置cookie并使用JavaScript检查cookie (或jQuery)。如果cookie与先前请求的页面的cookie匹配,那么它是一个缓存页面。如果没有,那就是一个新的页面。

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.

希望有所帮助。

这篇关于通过jQuery检测浏览器缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆