我如何知道图像是否正确缓存?

时间:2012-01-24 03:51:28

标签: ruby-on-rails caching ruby-on-rails-3.1 heroku

我正在Heroku上托管一个Rails应用程序,不确定我的静态图像是否被缓存。以下是我加载相同图像三次的日志。最后两个请求是从缓存提供的吗? “陈旧,无效,存储”是什么意思?

这些只是静态资产,我没有在Rails 3.1中使用资产管道

    2012-01-24T03:37:27+00:00 app[web.1]: cache: [GET /images/offer-new-reward-button.png?1327376077] miss, store
    2012-01-24T03:37:27+00:00 heroku[nginx]: (ip) - - [24/Jan/2012:03:37:27 +0000] "GET /images/offer-new-reward-button.png?1327376077 HTTP/1.1" 200 3692 "-" "curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5" myapp.heroku.com
    2012-01-24T03:37:27+00:00 heroku[router]: GET myapp.heroku.com/images/offer-new-reward-button.png dyno=web.1 queue=0 wait=0ms service=8ms status=200 bytes=3692

    2012-01-24T03:37:52+00:00 app[web.1]: cache: [GET /images/offer-new-reward-button.png?1327376077] stale, invalid, store
    2012-01-24T03:37:52+00:00 heroku[nginx]: (ip) - - [24/Jan/2012:03:37:52 +0000] "GET /images/offer-new-reward-button.png?1327376077 HTTP/1.1" 200 3692 "-" "curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5" myapp.heroku.com
    2012-01-24T03:37:52+00:00 heroku[router]: GET myapp.heroku.com/images/offer-new-reward-button.png dyno=web.1 queue=0 wait=0ms service=6ms status=200 bytes=3692

    2012-01-24T03:38:25+00:00 app[web.1]: cache: [GET /images/offer-new-reward-button.png?1327376077] stale, invalid, store
    2012-01-24T03:38:25+00:00 heroku[router]: GET myapp.heroku.com/images/offer-new-reward-button.png dyno=web.1 queue=0 wait=0ms service=7ms status=200 bytes=3692
    2012-01-24T03:38:25+00:00 heroku[nginx]: (ip) - - [24/Jan/2012:03:38:25 +0000] "GET /images/offer-new-reward-button.png?1327376077 HTTP/1.1" 200 3692 "-" "curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5" myapp.heroku.com

1 个答案:

答案 0 :(得分:1)

由于您似乎没有在Cedar堆栈上运行,因此您的静态文件应自动使用Varnish进行缓存。

此处有更多信息:http://devcenter.heroku.com/articles/http-caching

要测试您的缓存,只需获取其中一个图片并查看响应标头。你应该看到这里设置的缓存标题以及Varnish的via标题。