要求浏览器缓存尽最大可能地 [英] Asking browsers to cache as aggressively as possible

查看:142
本文介绍了要求浏览器缓存尽最大可能地的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于一个Web应用程序供应的图像。由于相同的请求将总是返回相同的形象,我想访问浏览器尽最大可能地缓存图像。我pretty多想告诉浏览器

This is about a web app that serves images. Since the same request will always return the same image, I want the accessing browsers to cache the images as aggressively as possible. I pretty much want to tell the browser

这是你的形象。继续前进,保持它;它真的不会改变在未来几天。无需回来。真。我答应了。

Here's your image. Go ahead and keep it; it's really not going to change for the next couple of days. No need to come back. Really. I promise.

我做的,到目前为止,集

I do, so far, set

Cache-Control: public, max-age=86400
Last-Modified: (some time ago)
Expires: (two days from now)

当然返回 304不修改如果要求有相应的的If-Modified-Since的头。

and of course return a 304 not modified if the request has the appropriate If-Modified-Since header.

还有什么我可以做(或什么我应该做不同),以获得我的信息传达给浏览器?

Is there anything else I can do (or anything I should do differently) to get my message across to the browsers?

该应用程序托管在谷歌应用程序引擎,在这种情况下,重要的

The app is hosted on the Google App Engine, in case that matters.

推荐答案

您可能有兴趣在检查出以下谷歌code文章:

You may be interested in checking out the following Google Code article:

  • Optimize caching: Leverage browser caching

在简单地说,所有现代浏览器应该能够适当地缓存图像的指示,与HTTP标头。

In a nutshell, all modern browsers should be able to cache your images appropriately as instructed, with those HTTP headers.

这篇关于要求浏览器缓存尽最大可能地的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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