apache expiryByType configuration
I am following the suggestion from pagespeed to set a expiry header for most resources, however, I can't seem to set the configuration for all hosts served, it only works if I set it for one single virtualHost wwww.example.com. And example.com would not successfully set an expiry header. I have the following Apache configuration.
How do I get both www.example.com and example.com to set expiry date successfully?
<VirtualHost *:80>
Serve开发者_JS百科rName www.example.com
ServerAlias example.com
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 day"
In your server's main httpd.conf file, enter a line like:
Include conf.d/expiry_settings.conf
Then create the file above, and enter whatever settings you would want there. Just take notice that the settings you will enter will be server-wide, meaning that all hosted domains on that server will have same expiry settings.
To overwrite those for a particular domain, use local .htaccess files of course.
Good luck.
精彩评论