Title: Filename based asset cache busting
Author: benlumley
Published: <strong>2016 年 3 月 24 日</strong>
Last modified: 2020 年 4 月 27 日

---

搜索插件

![](https://ps.w.org/filename-based-asset-cache-busting/assets/banner-772x250.png?
rev=2292252)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/filename-based-asset-cache-busting/assets/icon-256x256.png?
rev=2292252)

# Filename based asset cache busting

 作者：[benlumley](https://profiles.wordpress.org/benlumley/)

[下载](https://downloads.wordpress.org/plugin/filename-based-asset-cache-busting.zip)

 * [详情](https://cn.wordpress.org/plugins/filename-based-asset-cache-busting/#description)
 * [评价](https://cn.wordpress.org/plugins/filename-based-asset-cache-busting/#reviews)
 * [开发进展](https://cn.wordpress.org/plugins/filename-based-asset-cache-busting/#developers)

 [支持](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/)

## 描述

Filename based cache busting for WordPress scripts/styles using last modified date.

Stop telling clients or users to hard refresh / shift refresh. The url to all of
the css/js files on your site will change automatically whenever the files are modified.
You can set proper long cache lifetimes to help get top scores on Google Pagespeed
without running into cached css/javascript problems.

Based on this gist https://gist.github.com/ocean90/1966227 from Dominik Schilling,
I’ve enhanced it by automatically replacing the asset version with the files modification
time and automatically editing htaccess – making it install + forget.

Includes querystring option as a fallback – which works in more scenarios.

### Webservers

#### Apache

The plugin should add what it needs to your .htaccess file jsut like WP itself. 
But if for any reason that doesn’t work for you – here’s what it adds:

    ```
    # FBACB
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.+)\.([0-9\.]+)\.(js|css)$ $1.$3 [L]
    </IfModule>

    # still fbacb
    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresByType text/css                            "access plus 1 year"
        ExpiresByType application/javascript              "access plus 1 year"
    </IfModule>
    # END FBACB
    ```

#### NGINX

    ```
     location ~* ^(.+)\.(?:\d+)\.(min.js|min.css|js|css)($|\?.*$) {
       try_files $uri $1.$2;
     }
    ```

### Host specific notes

Some webhosts need a bit of custom config to get the filename based urls working.

#### WP Engine

To work on WP-Engine, you’ll need the following redirect added via my.wpengine -
> installname -> Redirect rules

    ```
     Source: ^(.+)\.([0-9\.]+)\.(js|css)$
     Dest: $1.$3
     Type: break (this is under advanced)
    ```

#### CloudWays

Just works.

#### Flywheel

Just works.

#### PHP Fallback

If your webserver is failing to serve assets using url rewriting, the plugin attempts
to serve them itsef (ie: via PHP). Obviously this is slow/less than ideal in production(
it’ll be much slower) – so you should configure your web server correctly to serve
the files. If you see this HTTP header “FBACB-Php-Fallback: yes” on your assets,
this applies to you.

Note that hosts are increasingly configured to serve css/js directly from disk and
won’t fall back to PHP + WordPress error handling – this fallback then won’t work.

## 评价

![](https://secure.gravatar.com/avatar/b2636d2a5257aadb4cb9bc26df8cddf61636dc595e1bd3c6dbf463d2ba746246?
s=60&d=retro&r=g)

### 󠀁[Great Plugin to avoid hitting ctrl+f5 after every change in css and js file](https://wordpress.org/support/topic/great-plugin-to-avoid-hitting-ctrlf5-after-every-change-in-css-and-js-file/)󠁿

 [Sumit P](https://profiles.wordpress.org/sumit_p/) 2019 年 6 月 27 日

I was looking for something like Laravel’s Elixir Cache bursting solution and found
this plugin. Works great. To use this in nginx, add below line inside the server
block of your site’s nginx configuration # Support for Filename-based asset cache
busting Plugin location ~* \.(?:css|js)$ { if (!-e $request_filename){ rewrite ^/(.
+)\.([0-9\.]+)\.(js|css)$ /$1.$3 break; } }

![](https://secure.gravatar.com/avatar/1789084fde3e5938b7cf1d1c69e0ffb87b34c6012624c1910bd8c540d1677b05?
s=60&d=retro&r=g)

### 󠀁[Very useful and simple](https://wordpress.org/support/topic/very-useful-and-simple-8/)󠁿

 [neomobil](https://profiles.wordpress.org/neomobil/) 2017 年 10 月 22 日

Very useful and simple plugin. Should be the first one to choose. Thank you!

![](https://secure.gravatar.com/avatar/6a864fbf455e5ee6903e10a35597142f7e5c65de03166dad2747f4d86542a50e?
s=60&d=retro&r=g)

### 󠀁[Great plugin!](https://wordpress.org/support/topic/great-plugin-13573/)󠁿

 [loseveny](https://profiles.wordpress.org/loseveny/) 2017 年 4 月 19 日

Thanks for making this, simple, easy use and powerful! it helps me lot.

![](https://secure.gravatar.com/avatar/c0dc7bb18d5c14e0586dd87fc9adf97d7cb6055417e1caa845cfdded2cfa3233?
s=60&d=retro&r=g)

### 󠀁[plugin is a lifesaver](https://wordpress.org/support/topic/plugin-is-a-lifesaver/)󠁿

 [James Maiden](https://profiles.wordpress.org/reallygreenjames/) 2017 年 4 月 3
日

If you run a site that users browser caching, and you should, you should also be
using some kind of cache busting. This plugin make it easy.

![](https://secure.gravatar.com/avatar/819c1fcbd522899813c183f0a5c820e38598031bfaa62cd5bb9a44b500d6c2b0?
s=60&d=retro&r=g)

### 󠀁[works as advertised](https://wordpress.org/support/topic/works-as-advertised-388/)󠁿

 [bobhhh](https://profiles.wordpress.org/bobhhh/) 2017 年 1 月 10 日

works as advertised

 [ 阅读所有5条评价 ](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/)

## 贡献者及开发者

「Filename based asset cache busting」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ benlumley ](https://profiles.wordpress.org/benlumley/)
 *   [ Dominik Schilling ](https://profiles.wordpress.org/ocean90/)

[帮助将「Filename based asset cache busting」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/filename-based-asset-cache-busting)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/filename-based-asset-cache-busting/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/filename-based-asset-cache-busting/)，
或通过[RSS](https://plugins.trac.wordpress.org/log/filename-based-asset-cache-busting/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/filename-based-asset-cache-busting/)。

## 额外信息

 *  版本 **1.4**
 *  最后更新：**6 年前**
 *  活跃安装数量 **200+**
 *  WordPress 版本 ** 3.0.1 或更高版本 **
 *  已测试的最高版本为 **5.4.19**
 *  语言
 * [English (US)](https://wordpress.org/plugins/filename-based-asset-cache-busting/)
 * 标签
 * [asset](https://cn.wordpress.org/plugins/tags/asset/)[assets](https://cn.wordpress.org/plugins/tags/assets/)
   [css](https://cn.wordpress.org/plugins/tags/css/)[JS](https://cn.wordpress.org/plugins/tags/js/)
   [version](https://cn.wordpress.org/plugins/tags/version/)
 *  [高级视图](https://cn.wordpress.org/plugins/filename-based-asset-cache-busting/advanced/)

## 评级

 5 星（最高 5 星）。

 *  [  5 条 5 星评价     ](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/?filter=5)
 *  [  0 条 4 星评价     ](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/?filter=4)
 *  [  0 条 3 星评价     ](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/?filter=3)
 *  [  0 条 2 星评价     ](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/?filter=2)
 *  [  0 条 1 星评价     ](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/reviews/)

## 贡献者

 *   [ benlumley ](https://profiles.wordpress.org/benlumley/)
 *   [ Dominik Schilling ](https://profiles.wordpress.org/ocean90/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/filename-based-asset-cache-busting/)