cache-control

Nginx proxy_cache_key $request_body is ignored for large request body

两盒软妹~` 提交于 2019-12-04 04:28:17
I use nginx as a reverse proxy and I would like it to cache POST requests. My back-end is correctly configured to return appropriate cache-control headers for POST requests. In nginx I have configured: proxy_cache_methods POST; proxy_cache_key "$request_method$request_uri$request_body"; This works great for small HTTP POST requests. However I started noticing that for large requests (e.g. file uploads) it seems like the $request_body is ignored in the proxy_cache_key . When a form containing a file upload is submitted twice with completely different data, nginx will return the cached result.

How to know if NSURLSessionDataTask response came from cache?

Deadly 提交于 2019-12-04 03:16:28
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; 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 initial request with the NSURLRequestReturnCacheDataDontLoad cache policy, and if that fails, make a second

浏览器缓存详解:expires,cache-control,last-modified,etag详细说明

徘徊边缘 提交于 2019-12-04 02:14:31
最近在对CDN进行优化,对浏览器缓存深入研究了一下,记录一下,方便后来者 画了一个草图: 每个状态的详细说明如下: 1 、 Last-Modified 在浏览器第一次请求某一个 URL 时,服务器端的返回状态会是 200 ,内容是你请求的资源,同时有一个 Last-Modified 的属性标记 (HttpReponse Header) 此文件在服务期端最后被修改的时间,格式类似这样: Last-Modified:Tue, 24 Feb 2009 08:01:04 GMT 客户端第二次请求此 URL 时,根据 HTTP 协议的规定,浏览器会向服务器传送 If-Modified-Since 报头 (HttpRequest Header) ,询问该时间之后文件是否有被修改过: If-Modified-Since:Tue, 24 Feb 2009 08:01:04 GMT 如果服务器端的资源没有变化,则自动返回 HTTP304 ( NotChanged. )状态码,内容为空,这样就节省了传输数据量。当服务器端代码发生改变或者重启服务器时,则重新发出资源,返回和第一次请求时类似。从而保证不向客户端重复发出资源,也保证当服务器有变化时,客户端能够得到最新的资源。 注:如果 If-Modified-Since 的时间比服务器当前时间 ( 当前的请求时间 request_time) 还晚

Why doesn't Safari honor my cache-control directive?

江枫思渺然 提交于 2019-12-04 00:44:09
问题 There is a particular page that I would like the browser to always load, particularly when the user presses the browser back button to get to it. So I use the following 'Cache-Control' directive in the header for this page (taking the PHP directly from my code). $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; This works for FF, IE and Chrome, but Safari (5.0.1) seems to ignore the directive and fails to reload the page (across multiple users, so it doesn't seem

How to Set Varnish Cache-Control Headers

烂漫一生 提交于 2019-12-03 19:30:49
问题 I am hoping someone can advise on the proper method for getting Varnish to send cache-control headers. Currently, my configuration is sending "Cache-Control: no-cache" to clients. Thanks in advance to anyone who might be able to help... 回答1: Your back-end is sending "Cache-Control: no-cache" to Varnish which implies two things: Varnish will not store the response in the cache (so a next lookup will fail) Your clients (browsers and intermediate proxies) will not cache responses (and request

Any reason not to add “Cache-Control: no-transform” header to every page?

你。 提交于 2019-12-03 15:52:16
问题 We have recently fixed a nagging error on our website similar to the one described in How to stop javascript injection from vodafone proxy? - basically, the Vodafone mobile network was vandalizing our pages in transit, making edits to the JavaScript which broke viewmodels. Adding a "Cache-Control: no-transform" header to the page that was experiencing the problem fixed it, which is great. However, we are concerned that as we do more client-side development using JavaScript MVP techniques, we

Http详解

我的梦境 提交于 2019-12-03 14:34:47
1. HTTP请求格式 首先介绍HTTP协议: 超文本传输协议 (HTTP,HyperText Transfer Protocol)是 互联网 上应用最为广泛的一种 网络协议 。所有的 WWW 文件都必须遵守这个标准。 工作原理: 由HTTP客户端发起一个请求,建立一个到服务器指定端口(默认是 80端口 )的TCP连接。 连接 HTTP服务器则在那个端口监听客户端发送过来的请求。一旦收到请求, 请求 服务器(向客户端)发回一个状态行,比如"HTTP/1.1 200 OK",和(响应的)消息,消息的消息体可能是请求的文件、错误消息、或者其它一些信息。响应 客户端接收服务器所返回的信息通过浏览器显示在用户的显示屏上,然后客 http工作流程图 户机与服务器断开连接 显示内容 HTTP协议的网页 HTTP使用TCP而不是UDP的原因在于(打开)一个网页必须传送很多数据,而TCP协议提供传输控制,按顺序组织数据,和错误纠正。   做过Socket编程的人都知道,当我们设计一个通信协议时,“消息头/消息体”的分割方式是很常用的,消息头告诉对方这个消息是干什么的,消息体告诉对方怎么干。HTTP协议传输的消息也是这样规定的,每一个HTTP包都分为HTTP头和HTTP体两部分,消息体是可选的,而消息头是必须的。每当我们打开一个网页,在上面点击右键,选择“查看源文件”

持久化存储与HTTP缓存

老子叫甜甜 提交于 2019-12-03 13:17:11
本文主要学习一下一些高级的HTTP知识,例如 Session LocalStorage Cache-Control Expires ETag 其实主要就是涉及到了 持久化存储与缓存的技术 在此之前已经学习了 Cookie 的 相关知识 ,但是 Cookie 有个缺点是可以人为修改,有一定的安全隐患。 所以,针对这个缺点,诞生了 Session Session 一般来说 Session 是基于Cookie实现的,它利用一个 sessionId 把用户的敏感数据隐藏起来,除非暴力穷举才有可能获得敏感数据。 sessionId 我们使用 Cookie 的时候,一般是服务器给用户一个响应头,设置 Cookie response.setHeader('Set-Cookie', 'sign_in_email=...;HTTPOnly') 既然Session还是基于 Cookie 实现的,那么还是应该在 Set-Cookie 上搞事情。 //预先在服务器端预留对象准备存储各种session let sessions = { } ... let sessionId = Math.random() * 100000 sessions[sessionId] = {sign_in_email: email} response.setHeader('Set-Cookie', `sessionId=$

HTML - Cache control max age

孤街醉人 提交于 2019-12-03 10:56:50
I'ld like to present always the latest website content to the user but also have it fast loaded. By researching I came across postings people suggesting to use the cache for speeding up loading. So what do I need to add to my website to "overwrite" the cache after 3 days to display the latest content? calumbrodie There is more than one way to do this - but you need to consider exactly what you need to cache and what you don't. The biggest speed increases will likely come from making sure your assets (css, images, javascript) are cached, rather than the html itself. You then need to look at

How do I set the cachability of static files in IIS?

[亡魂溺海] 提交于 2019-12-03 08:54:56
I have some static images in a folder on my IIS 6-based website that I want to be downloaded as little as possible (to preserve bandwidth). I've set the Content Expiration to expire after 30 days. Is there anything else I can do in IIS to try to maximize the caching by browsers, proxy, and gateway caches? Such as adding a Cache-Control header? Anything else? Mischa Kroon http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx This is a blog post covering the following: Allow overriding static content setting set cache settings using following commands