开发者

readfile/fpassthru web caching

I have noticed that files delivered by PHP through readfile or fpa开发者_如何转开发ssthru techniques are never cached by the browser.

How can I "encourage" browsers to cache items delivered via these methods?


Whether your content is cached or not has nothing to do with readfile() and consorts, but probably the default caching headers issued by the server (that would activate caching for HTML pages and image resources) don't apply when you use PHP to pass through files.

You will have to send the appropriate headers along with your content, telling the browser that caching for this resource is all right.

See for example

Caching tutorial for Web Authors and Webmasters

How to use HTTP cache headers with PHP


I ended up finding this page and using it as a starting point for my own implementation. The example code on this page, along with some of the reading Pekka pointed to, was a great springboard for me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜