开发者

How to get browser to use disk cache

开发者 https://www.devze.com 2023-03-13 09:39 出处:网络
Is there a trick to getting the browser to just use what is on disk. Wit开发者_运维百科h everything I try the browser keeps sending headers to the server and I have to send back 304. Here is what I\'v

Is there a trick to getting the browser to just use what is on disk. Wit开发者_运维百科h everything I try the browser keeps sending headers to the server and I have to send back 304. Here is what I've tried.

header('Last-Modified: ' . gmdate('D, d M Y H:i:s', OPTIMIZATION_CACHING_HEADER_DURATION + time()).' GMT');
header('Cache-Control: max-age='. OPTIMIZATION_CACHING_HEADER_DURATION. ', public');    // expires is not needed with this
header('Vary: Accept-Encoding');    // so that people don't get zipped file if they can't handle it
header('Content-Length: '.strlen($stylesheet));
header('Content-type: text/css');  // Correct MIME type

I've tried variations of this as well using time() as last-modified, used Expires instead of max-age. I saw


PICNIC - I've learned the hard way that refreshing the page will cause browsers to request the scripts again while using links to navigate will allow it to use disk cache. The headers above work as expected.

0

精彩评论

暂无评论...
验证码 换一张
取 消