[wordpress插件] Disable Version Caching禁用版本缓存

wordpress 插件 文章 2020-04-18 16:00 475 0 全屏看文

AI助手支持GPT4.0

评分
100
描述

Are you a frontend developer?

您是前端开发人员吗?

Do you want to clear browser cache for all users?

您是否要为所有用户清除浏览器缓存?

Just activate this plugin and show your work!

只需激活此插件并展示您的作品即可!

Disable Version Caching allows you to update the assets version of all CSS and JS files automatically or manually in one click.

“禁用版本缓存”使您可以自动或一键式更新所有CSS和JS文件的资产版本。

Now you can show the latest changes on the site without asking the client to clear the cache.

现在,您可以显示网站上的最新更改,而无需要求客户端清除缓存。

How it works?

它如何工作?

Usually, WordPress loads assets using query param “ver” in the URL (e.g., style.css?ver=4.9.6).

通常,WordPress使用URL中的查询参数“ ver”来加载资产(例如,style.css?ver = 4.9.6)。

It allows browsers to cache these files until the parameter will not be updated.

它允许浏览器缓存这些文件,直到不会更新参数为止。

To prevent caching of CSS and JS files, this plugin adds a unique number (eg, 1526903434) to the “ver” parameter (eg, style.css?ver=4.9.6.1526903434) for all links, loaded using wp_enqueue_style and

为防止缓存CSS和JS文件,此插件为所有链接(使用wp_enqueue_style和)加载了一个唯一编号(例如1526903434)到“ ver”参数(例如style.css?ver = 4.9.6.1526903434)。

wp_enqueue_script functions.

wp_enqueue_script函数。

For developers

面向开发人员

By default, this plugin updates all assets files every time a user loads a page and adds options in the admin panel (Settings -> Disable Version Caching) which allows you to configure updating of these files.

默认情况下,此插件在用户每次加载页面时都会更新所有资产文件,并在管理面板(设置->禁用版本缓存)中添加选项,该选项可让您配置这些文件的更新。

But you can also set the version of CSS and JS files programmatically.

但是您还可以通过编程方式设置CSS和JS文件的版本。

Just insert this code in functions.php file of your theme and change the value of assets_version when you need to update assets:

只需将此代码插入您主题的functions.php文件中,并在需要更新资产时更改asset_version的值:

disable_version_caching( array(    

  disable_version_caching(array(    

'assets_version' => '123'

'assets_version'=>'123'

) );

));

安装步骤

From WordPress dashboard

从WordPress仪表板中

    1. Visit “Plugins > Add New”.
    2. 访问“插件>添加新内容”。

    3. Search for “Disable Version Caching”.
    4. 搜索“禁用版本缓存”。

    5. Install and activate Disable Version Caching plugin.
    6. 安装并激活“禁用版本缓存”插件。

    From WordPress.org site

    来自WordPress.org网站

      1. Download Disable Version Caching plugin.
      2. 下载禁用版本缓存插件。

      3. Upload the “disable-version-caching” directory to your “/wp-content/plugins/” directory.
      4. 将“ disable-version-caching”目录上传到“ / wp-content / plugins /”目录。

      5. Activate Disable Version Caching on your Plugins page.
      6. 在“插件”页面上激活禁用版本缓存。

下载地址
https://downloads.wordpress.org/plugin/disable-version-caching.zip
-EOF-

AI助手支持GPT4.0