Google 网站站长工具利用缓存

Google Webmaster Tools leverage caching

我不明白这个反馈。我已经为静态资源启用了 24 小时缓存。那么为什么我会看到反馈?缓存太短了吗?

Headers 受影响的资源之一:

Response headers
----------------
Accept-Ranges:bytes
Cache-Control:public, max-age=86400
Connection:keep-alive
Content-Length:2123
Content-Type:image/png
Date:Mon, 20 Apr 2015 23:51:45 GMT
ETag:W/"84b-3727224626"
Last-Modified:Mon, 20 Apr 2015 12:57:43 GMT

Request Headers
---------------
Accept:image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,da;q=0.6
AlexaToolbar-ALX_NS_PH:AlexaToolbar/alxg-3.3
Cache-Control:no-cache
Connection:keep-alive
Cookie:xxxxxxx
DNT:1
Host:xxxxxxxxx
Pragma:no-cache
Referer:http:xxxxxxxxxx
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36 

这就是我在 Node.js 中设置缓存的方式:

app.use(express.static(path.join(__dirname, '../', config.get('staticContentPath')), {
        maxAge: (60 * 60 * 24) * 1000 // 24 hrs x 1000 because Express middleware expects miliseconds and not seconds
    }));

我相信你的假设是正确的。

Here 它说:

This rule triggers when PageSpeed Insights detects that the response from your server does not include caching headers or if the resources are specified to be cached for only a short time.

再往下:

We recommend a minimum cache time of one week and preferably up to one year for static assets, or assets that change infrequently. If you need precise control over when resources are invalidated we recommend using a URL fingerprinting or versioning technique - see invalidating and updating cached responses link above.