[wordpress插件] Browser Caching with .htaccess使用.htaccess进行浏览器缓存

wordpress 插件 文章 2020-03-11 20:40 449 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

With Browser Caching you can tell Browsers when your files usually change, e.g.

使用浏览器缓存,您可以告诉浏览器文件通常何时更改,例如

every month, every week, etc. This will fasten up your website because Browser will only make requests to your Server after the declared time.

每个月,每个星期等。这将加快您的网站的速度,因为Browser仅在声明的时间之后向您的服务器发出请求。

PageSpeed is a Google Ranking Factor so it is important to have a fast website.

PageSpeed是Google的排名因素,因此拥有一个快速的网站非常重要。

There a several ways to enable Browser Caching.

有几种启用浏览器缓存的方法。

This Plugin uses Expires.

该插件使用Expires。

The following code will be added to your .htaccess file:

以下代码将添加到您的.htaccess文件中:

ExpiresActive On

ExpiresActive On

ExpiresByType text/css “access plus 1 month”

ExpiresByType文本/ css“访问权限加1个月”

ExpiresByType text/javascript “access plus 1 month”

ExpiresByType文本/ javascript“访问权限加1个月”

ExpiresByType text/html “access plus 1 month”

ExpiresByType text / html“访问权限加上1个月”

ExpiresByType application/javascript “access plus 1 month”

ExpiresByType应用程序/ javascript“访问权限加1个月”

ExpiresByType application/x-javascript “access plus 1 month”

ExpiresByType应用程序/ x-javascript“访问权限加1个月”

ExpiresByType application/xhtml-xml “access plus 1 month”

ExpiresByType应用程序/ xhtml-xml“访问权限加1个月”

ExpiresByType image/gif “access plus 1 month”

ExpiresByType图片/ gif“访问权限加1个月”

ExpiresByType image/jpeg “access plus 1 month”

ExpiresByType图片/ jpeg“访问权限加1个月”

ExpiresByType image/png “access plus 1 month”

ExpiresByType image / png“访问权限加1个月”

ExpiresByType image/x-icon “access plus 1 month”

ExpiresByType图片/ x图标“访问权限加上1个月”

The second line means that css files will be requested after 1 month.

第二行表示1个月后将请求CSS文件。

The third line means that javascript files will be requested after 1 month and so on.

第三行表示将在1个月后请求javascript文件,依此类推。

Of course you can change the periods.

当然,您可以更改时间段。

You will find instructions for that in the FAQ section.

您可以在“常见问题解答”部分中找到相关说明。

In case you do not have reading rights to the .htaccess file you will get a 403 Permission Denied Error Page.

如果您没有对.htaccess文件的读取权限,则将获得403权限被拒绝错误页面。

So before activating this Plugin make sure you have reading rights to the .htaccess file (normally you have those rights).

因此,在激活此插件之前,请确保您具有.htaccess文件的读取权限(通常具有这些权限)。

安装步骤

    1. Upload the plugin directory ‘ browser_caching_htaccess’ to the ‘/wp-content/plugins/’ directory.
    2. 将插件目录“ browser_caching_htaccess”上传到“ / wp-content / plugins /”目录。

    3. Activate the plugin through the ‘Plugins’ menu in WordPress.
    4. 通过WordPress中的“插件”菜单激活插件。

    5. Go to ‘Tools’ in the Dashboard Sidebarand look for ‘Browser Caching’.
    6. 转到仪表板侧栏中的“工具”,然后查找“浏览器缓存”。

    7. Read the instructions on the Plugin Dahboard.
    8. 阅读插件面板上的说明。

    9. Check if your website has a .htaccess file.

    10. 检查您的网站是否具有.htaccess文件。

      You can either do this by pressing the button ‘check .htaccess file’ or look directly in your ‘root’ directory.

      您可以通过按“检查.htaccess文件”按钮执行此操作,也可以直接在“根”目录中查找。

      Make sure the file is writable.

    11. 确保文件可写。

    12. Also check if you are already using Browser Caching with ‘Expires’.

    13. 还要检查您是否已经在使用带有“过期”的浏览器缓存。

      Therefore search for the code shown above in your .htaccess file.

      因此,请在您的.htaccess文件中搜索上面显示的代码。

    14. If you are not already using Browser Caching with Expires press the ‘activate Browser Caching’ button and the code will get added to your .htaccess file.
    15. 如果您尚未使用带有Expires的浏览器缓存,请按“激活浏览器缓存”按钮,该代码将添加到您的.htaccess文件中。

    16. DONE!
    17. 完成!

下载地址
https://downloads.wordpress.org/plugin/browser-caching-with-htaccess.zip
-EOF-

AI助手支持GPT4.0