Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-cache与max-age=0 #1

Open
brunoyang opened this issue Sep 20, 2015 · 1 comment
Open

no-cache与max-age=0 #1

brunoyang opened this issue Sep 20, 2015 · 1 comment

Comments

@brunoyang
Copy link
Owner

今天又复习了一遍http协议,在看文档时,发现cache-control有很多指令,其中就包括一个max-age。
打开控制台,查看网络连接,当中有很多max-age都被设置成了0,我很疑惑,这和no-cacha有啥区别。进过一番谷歌,终于知晓其中区别。

相同之处

no-cache顾名思义是指该资源不会被缓存,而max-age会被缓存到本地,只是在下次重新访问该页面时又会强制地从服务器拉取资源。所以大部分情况下,这俩其实是一样的。

不同之处

当点击浏览器的前进后退按钮时,被no-cache的资源会重新加载;而被设置成max-age的读取则会从本地读取资源。当然这也需要根据浏览器实现的情况来看,某些浏览器如IE9之前的IE,并没有遵循http协议,直接统一了这两个字段的行为为no-cache.

@iamwjj
Copy link

iamwjj commented Jun 10, 2020

这已经是5年前写的了。。想问个问题,在浏览器输入部分url时,浏览器会出现历史访问的地址,然后直接点击地址进行访问,这种情况是不是也会从本地缓存读取资源?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants