performance - Google PageSpeed - 设置到期日期

标签 performance apache caching memcached centos

我正在使用 CentOS 5 32 位,我刚刚在 Google 上扫描了我的网站以了解页面速度,它给了我以下信息:

“在静态资源的 HTTP header 中设置到期日期或最长期限会指示浏览器从本地磁盘而不是通过网络加载以前下载的资源。”

有人可以让我知道如何在我的 Apache 服务器中启用它吗?

最佳答案

首先确保 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>

希望这可以帮助 !

关于performance - Google PageSpeed - 设置到期日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13039691/

相关文章:

css - 用于缓存破坏的 css 中图像的 URL 版本控制

ios - UIScrollView性能问题

Java 性能问题

c++ - 与锁相比,无论有无争用,原子/互锁变量的速度有多快?

apache - .htaccess 中用于 index.php 查询参数的 URL RewriteRule

php - Memcache city lookup table 与否

javascript - 为了性能更好,两个函数在同一个 setInterval() 中还是两个不同的 setInterval 中? - JavaScript

linux - 运行 Apache/Linux 的 AWS EC2 中的密码保护目录

apache - 如何通过 REST API 将用户添加到 Apache Ranger

c - malloc:从内存中获取信息