• 修改.htaccess文件提升网站访问速度方法


    简单点说:就是缓存一下不常修改的文件,提升访问速度。再简单点说:就是在.htaccess文件中写入以下内容。

    有时候遇到一个比较复杂的问题,我会选择暂时放一放。

    YSlow的检测结果,当时优化掉几个问题后,就暂时放手了。

    最近在网站优化上有了新的认识,应用一下:

    1. Add an Expires or a Cache-Control Header

      简单点说:就是缓存一下不常修改的文件,提升访问速度。
      再简单点说:就是在.htaccess文件中写入以下内容:

      <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresDefault A600
      ExpiresByType image/x-icon A2592000
      ExpiresByType application/x-javascript A2592000
      ExpiresByType text/css A604800
      ExpiresByType image/gif A2592000
      ExpiresByType image/png A2592000
      ExpiresByType image/jpeg A2592000
      ExpiresByType text/plain A86400
      ExpiresByType application/x-shockwave-flash A2592000
      ExpiresByType video/x-flv A2592000
      ExpiresByType application/pdf A2592000
      ExpiresByType text/html A600
      </IfModule>

      text/css之类代表文件类型,A2592000表示在浏览器中的缓存时间,2592000秒=30天。

    2. Gzip components

      Gzip压缩是减少文件体积增加用户体验的简单方法,
      同样,添加以下代码到.htaccess文件即可。

      <ifmodule mod_deflate.c>
      AddOutputFilter DEFLATE html xml php js css
      </ifmodule>

    3. 配置ETag

      这段话我没看明白,总之结论是:如果你没有使用ETag提供的灵活的验证模式,那么干脆把所有的ETag都去掉会更好。

      我的网站只放在一台服务器上,我写.htaccess关了它:

      FileETag none

  • 相关阅读:
    增删改
    创建数据库
    数据库的列类型
    数据库
    Python os.ttyname() 方法
    Python os.tmpnam() 方法
    Python os.tmpfile() 方法
    Python os.tempnam() 方法
    Python os.tcsetpgrp() 方法
    LR运行负载测试场景-笔记
  • 原文地址:https://www.cnblogs.com/derrck/p/1552868.html
Copyright © 2020-2023  润新知