admin管理员组

文章数量:1336632

In reviewing the answer to this post, I don't understand why 0 seconds is used for best practice here:

ExpiresByType text/html "access plus 0 seconds"

I think this means that whenever a user visits the website, the html page is always downloaded instead of pulled from cache. Is that right?

Is this what people typically set for this variable? If so why? If not, which scenarios benefit from setting it to 0 seconds?

In reviewing the answer to this post, I don't understand why 0 seconds is used for best practice here:

ExpiresByType text/html "access plus 0 seconds"

I think this means that whenever a user visits the website, the html page is always downloaded instead of pulled from cache. Is that right?

Is this what people typically set for this variable? If so why? If not, which scenarios benefit from setting it to 0 seconds?

Share Improve this question edited May 23, 2017 at 11:59 CommunityBot 11 silver badge asked Oct 30, 2013 at 20:27 ggkmathggkmath 4,25624 gold badges76 silver badges133 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

If text/html only meant "content from static HTML files", you'd be right, and you'd want to set a longer cache life. But server-side scripts typically also return a web page; that is, their responses' Content-Type will often be text/html as well. And if all HTML were cached, dynamically generated content might not appear to update properly.

If you wanted to expire only non-static HTML, you might be able to do something like

<FilesMatch "\.php$">
    ExpiresByType text/html "access plus 0 seconds"
</FilesMatch>

(using PHP as an example).

本文标签: