我写一个小的应用程序,它从本地计算机图像服务,使他们能够为 HTTP访问://本地主机:12345 /东西/ 的东西(它返回一个JPEG)。
I am writing a small application which serves images from the local computer, so they can be accessed as localhost:12345/something/something (which returns a jpeg).
如何可以强制浏览器缓存此,因此只有一个单一的请求将被发送到服务器。将这个头就足够了。
How can I force the browser to cache this, so only a single request would be sent to the server. Would this header be sufficient
HTTP/1.1 200 OK Cache-Control: public, max-age=99936000 Content-Length: 123456 Content-Type: image/jpeg这似乎与3.X Firefox的工作,但它足以为全球浏览器等也?
This seems to work with Firefox 3.x but would it be sufficient globally for other browser as well?
推荐答案一个修改和过期头也可能是有益的补充。
A Last-Modified and Expires header might also be useful additions.
您的服务器还应该检查设有一个如果-Modified-Since的头,并返回一个304未修改响应,如果可能的飞驰的东西。
Your server should also check for requests featuring an If-Modified-Since header, and return a 304 Not Modified response if possible to speed things along.
更多推荐
如何强制Web浏览器缓存图片
发布评论