cache-control

How to know if NSURLSessionDataTask response came from cache?

瘦欲@ 提交于 2020-01-01 09:22:45
问题 I would like to determine if the response from NSURLSessionDataTask came from cache, or was served from server I'am creating my NSURLSessionDataTask from request.cachePolicy = NSURLRequestUseProtocolCachePolicy; 回答1: Two easy options come to mind: Call [[NSURLCache sharedURLCache] cachedResponseForRequest:request] before you make the request, store the cached response, then do that again after you finish receiving data, and compare the two cached responses to see if they are the same. Make an

Forcing AJAX request to revalidate cache with server, without reloading completely

那年仲夏 提交于 2020-01-01 09:08:11
问题 I have a web application that lets the browser cache AJAX requests result for a long time. I have found out how to make a request that bypasses the cache entirely, when probable modifications are detected. But I would want to let the user trigger a data refresh. In this scenario, I'd like the browser to check with the server if the cache is stalled but use it if it is not (that is, if the server responds with a 304 code). The goal is to spare the loading time because the data is huge. The

Cache control and expires header for PHP

泪湿孤枕 提交于 2020-01-01 04:55:11
问题 I'm setting my headers $offset = 60 * 15; header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"); header("Cache-Control: max-age=$offset, must-revalidate"); However when running FireBug its giving me the following header information HTTP/1.1 200 OK Date: Mon, 25 Jul 2011 12:15:12 GMT Server: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 X-Powered-By: PHP/5.2.9 Expires: Sat, 01 Jan 2000 00:00:01 GMT Cache-Control: post-check=0, pre-check=0, max-age=0

前端HTTP 缓存简单了解

China☆狼群 提交于 2019-12-31 12:58:51
始发掘金: 《前端HTTP 缓存简单了解》 同步到博客园。 HTTP 缓存简单了解。文章整理了相关资料,记录了部分实践。方便大家轻松了解缓存。能回答上三个问题,HTTP缓存就算理解呢。能否缓存?缓存是否过期?协商缓存? 概要: web缓存 缓存的处理 前端解决方案 总结 1. web缓存 Web缓存是可以自动保存常见文档副本的 HTTP 设备。当 Web请求抵达缓存时, 如果本地有“已缓存的”副本,就可以从本地存储设备而不是原始服务器中提取这个文档。《HTTP权威指南》 缓存是一种存储给定资源副本并在请求时将其提供回来的技术。 当Web缓存在其存储中具有请求的资源且能用时,它将拦截该请求并返回其副本,而不是从原始服务器重新下载。 关键字:缓存,原始服务器(产生原始文档) 1.1 缓存类型 缓存的种类:浏览器缓存(本文讨论点),代理缓存,网关缓存。 以上种类 缓存工作的原理 是一致的,只是缓存所在的位置不同,涉及面更宽广。 这几种缓存,可以分为两大类: 专用缓存(私有缓存):私有缓存专用于单个用户。 共享缓存:多用户共享。 图片源:HTTP caching 上图展示了: 没有缓存: 没有缓存直接向服务器请求资源。 共享缓存: 当用户Browser1请求资源,经过缓存服务器,缓存服务器也没有资源,向原始服务器请求资源。得到资源后,缓存服务器缓存资源并返还数据给Browser1

What happens if the origin web server sets the expires value in response header as a time which is passed relatively long ago?

家住魔仙堡 提交于 2019-12-30 09:54:09
问题 What happens if the origin web server sets the expires value in response header as a time which is passed relatively long ago. For instance, consider current time is Fri, 25 Jan 2013 GMT, and the expire header is set as --> Expires: Thu, 01 Dec 1994 16:00:00 GMT How will the client respond for the above instance? Any help would be appreciated 回答1: Responding with a past date in the Expired header (earlier than the Date header value) makes no sense and would be a sign of some serious

tomcat security-constraint impact cache

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 08:08:44
问题 I have a problem in caching my application. when this code is added to web.xml of tomcat : <security-constraint> <web-resource-collection> <web-resource-name>HTTPSOnly</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> I get this response : Cache-Control private Date Tue, 18 Feb 2014 01:18:17 GMT Etag W/"200-1391558564593" Expires Thu, 01 Jan

tomcat security-constraint impact cache

青春壹個敷衍的年華 提交于 2019-12-30 08:08:05
问题 I have a problem in caching my application. when this code is added to web.xml of tomcat : <security-constraint> <web-resource-collection> <web-resource-name>HTTPSOnly</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> I get this response : Cache-Control private Date Tue, 18 Feb 2014 01:18:17 GMT Etag W/"200-1391558564593" Expires Thu, 01 Jan

Cache-Control headers repeated; valid or not? (Nginx)

坚强是说给别人听的谎言 提交于 2019-12-29 07:22:09
问题 I've got a resource in my Nginx that is configured like this: location ~ foo\.js$ { add_header Cache-Control public; expires 1d; } If I open this with Firebug and look at the headers it shows this: Cache-Control max-age=86400, public The site is using HTTPS so I want to make sure I get it right because apparently browsers don't cache it unless it's max-age>0 AND public . See this But what happens with my Nginx when I use curl -Ik https://... is that it says: ... Expires: Sat, 22 Jan 2011 18

Can I force .htaccess to refresh?

折月煮酒 提交于 2019-12-29 05:44:09
问题 We are moving a site from one CMS to another. The .htaccess file has been changed and it needs to be refreshed for the new site to work right. From what I understand the .htaccess file will only be refreshed if the browser cache is cleared? It is fine for those creating the site to clear our cache, but is there a way to get the users' browsers to get the new .htaccess file without the user clearing cache manually on his own initiative? 回答1: If you're using RewriteRule, just use R instead of R

MOD_EXPIRES安装和配置 提高网站速率

╄→尐↘猪︶ㄣ 提交于 2019-12-29 03:15:39
MOD_EXPIRES安装和配置 提高网站速率 实施这一方法将节省你难以置信数额的带宽,极大地加快你的网站为你的网站访客。基本上,对于图片,CSS , JavaScript以及其他文件可以通过优化更快的下载,告诉你的网站访问者快取记忆体,为他们在某一段时间内。默认的行为是每一次请求检查文件的 last-modified 和/或者 Etag headers。 所以一个用户去/home/index.html,及浏览器缓存所有图象和文件。然后用户离开网站稍后回来,与浏览器发送If-Modified-Since 有条件的GET 请求为每一个缓存的项目时,基本上看,如果文件已被改变和他们必须更新他们的缓存。 当你执行在这篇文章中所述的缓存方法,你可以指定某文件或扩展名被缓存为某一特定数额的时间。这些文件然后缓存在你的网站访客和他们不发送If-Modified-Since头直到设置的缓存时间已经到了。 #================================================= ============================# # TIME CHEAT SHEET #================================================= ============================# # 300 5 M # 604800