简体   繁体   English

Google PageSpeed - 设置到期日期

[英]Google PageSpeed - Setting an expiry date

I'm using a CentOS 5 32bit and I've just scanned my site on Google for page speed and it gave me the following: 我使用的是CentOS 5 32bit,我刚刚在Google上扫描了我的网站以获得页面速度,它给了我以下内容:

"Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network." “在静态资源的HTTP标头中设置过期日期或最长期限,指示浏览器从本地磁盘而不是通过网络加载以前下载的资源。”

Can someone please let me know how can I enable this within my Apache server? 有人可以告诉我如何在我的Apache服务器中启用它?

First ensure that mod_expires has been loaded then ,you can define in httpd.conf file or inside VirtualHost following: 首先确保已加载mod_expires然后,您可以在httpd.conf文件或VirtualHost内部定义以下内容:

   <IfModule mod_expires.c>
   FileETag MTime Size
   ExpiresActive on

   ExpiresByType application/javascript "access plus 1 week"
   ExpiresByType application/x-javascript "access plus 1 week"
   ExpiresByType application/x-shockwave-flash "access plus 1 week"

   ExpiresByType text/css "access plus 1 week"

   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 image/x-icon "access plus 6 month"
   ExpiresByType image/ico "access plus 6 month"

   </IfModule>

Hope this helps ! 希望这可以帮助 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM