Title: Prevent Browser Caching
Author: kostyatereshchuk
Published: <strong>October 30, 2017</strong>
Last modified: July 6, 2026

---

Search plugins

![](https://ps.w.org/prevent-browser-caching/assets/banner-772x250.png?rev=3595847)

![](https://ps.w.org/prevent-browser-caching/assets/icon-256x256.png?rev=1793665)

# Prevent Browser Caching

 By [kostyatereshchuk](https://profiles.wordpress.org/kostyatereshchuk/)

[Download](https://downloads.wordpress.org/plugin/prevent-browser-caching.3.1.0.zip)

[Live Preview](https://vec.wordpress.org/plugins/prevent-browser-caching/?preview=1)

 * [Details](https://vec.wordpress.org/plugins/prevent-browser-caching/#description)
 * [Reviews](https://vec.wordpress.org/plugins/prevent-browser-caching/#reviews)
 *  [Installation](https://vec.wordpress.org/plugins/prevent-browser-caching/#installation)
 * [Development](https://vec.wordpress.org/plugins/prevent-browser-caching/#developers)

 [Support](https://wordpress.org/support/plugin/prevent-browser-caching/)

## Description

You changed the site, but a client or visitor still sees the old version and you
have to say “please clear your browser cache”? This plugin makes that conversation
unnecessary.

Prevent Browser Caching makes sure browsers always load the current version of your
site — without disabling browser caching and slowing the site down.

#### What it does

 * **CSS & JS versions.** WordPress loads assets with a “ver” URL parameter (e.g.`
   style.css?ver=4.9.6`). Browsers cache the file until this parameter changes. 
   In the recommended automatic mode the plugin sets the version from the file’s
   own modification time: browser caching works at full strength, and the moment
   you update a file every visitor gets the new one.
 * **Image versions.** When you edit or replace a file in the Media Library, visitors
   get the new image instead of the cached one.
 * **HTML page freshness.** Asks browsers to check for a newer version of a page
   before showing a cached copy — fixes “I still see the old page on my phone”.
 * **One-click update.** The “Update versions” toolbar button forces fresh copies
   of all assets for every visitor — and shows a short report of what exactly happened.
 * **Page cache stays in sync (opt-in).** If a page-cache plugin is active, updating
   versions can also clear its cache — so cached HTML stops referencing the old 
   file versions and every visitor sees the new site immediately. One checkbox turns
   it on, and after every update the plugin reports what was refreshed and what 
   happened to the page cache. Works with WP Rocket, LiteSpeed Cache, W3 Total Cache,
   WP Super Cache, WP Fastest Cache, WP-Optimize, Breeze, Cache Enabler, Hummingbird,
   SiteGround Optimizer, Swift Performance and Comet Cache.
 * **CLI & AI agents.** WP-CLI commands (`wp pbc update`, `wp pbc status`) and WordPress
   Abilities let deploy scripts and AI agents update versions safely.

#### Safe by default

 * External URLs (payment scripts, CDNs, third-party services) are left untouched—
   some of them break when an unexpected “ver” parameter is added. You can turn 
   external versioning back on with one checkbox.
 * Specific files (by part of the URL) or script/style handles can be excluded from
   versioning — CSS, JS and images alike.
 * If a page-cache plugin is active, the HTML freshness headers step aside automatically.
 * Another plugin’s page cache is never cleared unless you enable that yourself —
   the purge-on-update integration is opt-in, and the report after every update 
   tells you whether the page cache was cleared or left alone.

#### Update modes

 * **Automatically, when a file changes** (recommended) — version = file modification
   time. Zero clicks, full caching.
 * **Every time a page loads** — development mode: CSS & JS are never cached (images
   and pages are unaffected). Use it only while actively developing.
 * **Manually** — versions change only when you press the “Update versions” button.

#### For developers

The recommended way to set the CSS/JS version from code is the `pbc_assets_version`
filter. Add this to the functions.php file of your theme and change the value whenever
you need to update assets:

    ```
    add_filter( 'pbc_assets_version', function( $ver ) {
        return '123';
    } );
    ```

Because it uses WordPress’s own `add_filter()`, it keeps working safely even if 
the plugin is ever deactivated — your site won’t break.

Filters for fine-tuning:

 * `pbc_skip_src( $skip, $src, $handle )` — return `true` to leave a given asset
   URL untouched.
 * `pbc_assets_version( $ver, $src, $handle )` — change the version applied to a
   given asset.
 * `pbc_purge_page_cache( $purge, $plugin_name )` — return `false` to prevent the
   page-cache purge on version updates.
 * `pbc_after_bump( $result )` — action fired after every version update, with the
   new timestamp and the purge outcome.

#### WP-CLI

 * `wp pbc update` — updates the versions (and clears the detected page cache when
   the settings option is on). Add `--skip-purge` to leave the page cache alone 
   for that run.
 * `wp pbc status` — shows the mode, what is versioned, the last manual update and
   the detected page-cache plugin. Supports `--format=table|json|yaml`.

#### Abilities (AI agents & automation)

On WordPress 6.9+ the plugin registers two Abilities, discoverable via the Abilities
API, REST and the MCP adapter — so AI agents and site-management tools can operate
the plugin without custom glue code:

 * `prevent-browser-caching/bump-versions` — update the versions; optional boolean
   input `purge` (set `false` to skip the page-cache purge).
 * `prevent-browser-caching/status` — read-only report of the current configuration.

Both require the `manage_options` capability.

Legacy: earlier versions documented a `prevent_browser_caching()` function instead.
It still works exactly as before — it disables the plugin’s admin settings and gives
you full control — but I recommend the filter above: a bare function call in functions.
php triggers a fatal error if the plugin is ever deactivated. If you keep using 
the function, guard it:

    ```
    if ( function_exists( 'prevent_browser_caching' ) ) {
        prevent_browser_caching( array(
            'assets_version' => '123'
        ) );
    }
    ```

#### Thank you

Many of the improvements in 3.0.0 started as reports and questions in the [support forum](https://wordpress.org/support/plugin/prevent-browser-caching/)—
thank you to everyone who took the time to describe a problem or share an idea. 
If something doesn’t work as expected on your site, please open a topic there: it
genuinely helps make the plugin better for everyone.

## Screenshots

[⌊The settings page: choose what to keep fresh, when to update versions, and whether
to also clear the detected page cache.⌉⌊The settings page: choose what to keep fresh,
when to update versions, and whether to also clear the detected page cache.⌉[

The settings page: choose what to keep fresh, when to update versions, and whether
to also clear the detected page cache.

[⌊Upgrading from 2.x: your settings keep working as before, and one click enables
the recommended setup (reversible).⌉⌊Upgrading from 2.x: your settings keep working
as before, and one click enables the recommended setup (reversible).⌉[

Upgrading from 2.x: your settings keep working as before, and one click enables 
the recommended setup (reversible).

[⌊After a manual update the plugin reports what was refreshed and what happened 
to the page cache.⌉⌊After a manual update the plugin reports what was refreshed 
and what happened to the page cache.⌉[

After a manual update the plugin reports what was refreshed and what happened to
the page cache.

## Installation

#### From WordPress dashboard

 1. Visit “Plugins > Add New”.
 2. Search for “Prevent Browser Caching”.
 3. Install and activate Prevent Browser Caching plugin.

#### From WordPress.org site

 1. Download Prevent Browser Caching plugin.
 2. Upload the “prevent-browser-caching” directory to your “/wp-content/plugins/” directory.
 3. Activate Prevent Browser Caching on your Plugins page.

## FAQ

### Does it affect site speed or SEO?

No. In the recommended automatic mode browser caching keeps working at full strength—
repeat visitors load CSS/JS from their cache until a file really changes, so repeat
views are as fast as ever (faster than the old 2.x default, which re-downloaded 
assets on every visit). The server cost is a few file-time lookups per page — negligible.
The “ver” URL parameter is the same mechanism WordPress core uses, search engines
are perfectly used to it, and cache headers are not a ranking signal — the plugin
does not change your page content, markup or URLs seen by crawlers.

### Does it work together with page caching plugins?

Yes — and since 3.1.0 they can actively cooperate. Versioned asset URLs end up in
the cached HTML like any others, so serving stale HTML used to mean serving old 
asset versions with it. When the “Also clear the page cache” checkbox on the settings
page is enabled, pressing “Update versions” (toolbar, settings page, WP-CLI or an
ability) also clears the detected page-cache plugin’s cache, so that HTML is regenerated
with the new versions. Supported: WP Rocket, LiteSpeed Cache, W3 Total Cache, WP
Super Cache, WP Fastest Cache, WP-Optimize, Breeze, Cache Enabler, Hummingbird, 
SiteGround Optimizer, Swift Performance, Comet Cache. The checkbox is off by default—
another plugin’s cache is only touched when you say so (for example, if your page
cache serves logged-out visitors only, you may prefer not to rebuild it on every
update). Either way, the report shown after every update says whether the page cache
was cleared, and the version update always completes even if a purge fails. The 
plugin also keeps leaving HTML cache headers to the page-cache plugin.

### Does the automatic mode clear my page cache when a file changes?

No — and that’s by design, not an oversight. In the automatic mode the version comes
from the file’s modification time, read at the moment a page is rendered; nothing“
happens” on the server when you upload a changed file, so there is no event to clear
the page cache on. Cached HTML keeps the old asset versions until the page cache
expires or is cleared. After bigger changes, press “Update versions” — with the “
Also clear the page cache” option enabled, that both updates the versions and clears
the detected page cache in one click.

### Why don’t external files get a version by default?

Several external services — payment scripts in particular (PayPal, Braintree, Authorize.
net) — reject requests with an unexpected “ver” query parameter, which used to break
checkout forms. Since 3.0.0 only local files are versioned by default; there is 
a checkbox to include external URLs again if you relied on that.

### Do I lose browser caching with this plugin?

Not in the recommended automatic mode. Files are cached normally; the version only
changes when the file itself changes. The “every time a page loads” mode does disable
caching of CSS/JS — use it during active development only.

### The version does not update every X minutes as I set it. Why?

The legacy “every N minutes” mode works per visitor, using a cookie — it does not
rebuild anything on the server by cron. Each visitor gets a new assets version no
more often than the chosen interval. Since 3.0.0 the automatic mode is a better 
choice for almost every case.

### Does it version images inside post content?

Yes, when “Images” is enabled: attachment URLs rendered by WordPress get versions
immediately, and image URLs hardcoded in post content get the site-wide media version
after the first update (the “Update versions” button or replacing a media file).

### My CDN ignores query strings.

Then query-parameter versioning cannot bust that CDN’s cache for those files. Configure
the CDN to include query strings in its cache key, or use filename-based versioning(
e.g. replace a file under a new name).

### My site shows an error after I deactivate the plugin.

If you added `prevent_browser_caching( ... )` to your theme’s functions.php, that
line calls a function this plugin provides. Once the plugin is deactivated the function
no longer exists, so PHP stops with a fatal error. Two ways to fix it: switch to
the `pbc_assets_version` filter (recommended — it never causes this), or wrap the
call in `if ( function_exists( 'prevent_browser_caching' ) ) { ... }`. See “For 
developers” above.

## Reviews

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

### 󠀁[Very good](https://wordpress.org/support/topic/very-good-7474/)󠁿

 [robertorefresh](https://profiles.wordpress.org/robertorefresh/) November 25, 2024

It works great!

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

### 󠀁[Best Cache Plugin ever](https://wordpress.org/support/topic/best-cache-plugin-ever-16/)󠁿

 [rompikapo](https://profiles.wordpress.org/rompikapo/) May 17, 2024

It is the first plugin that I install every time I create a new site, this plugin
is the web designer’s best friend, it instantly clears the browser cache and refreshes
the page with one click, saving me a lot of time when I update and design the site,
avoiding long trips in the browser, also works to show the page to customers, a 
heartfelt thank you.

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

### 󠀁[MAGIC!!!](https://wordpress.org/support/topic/magic-64/)󠁿

 [teacherdesigner](https://profiles.wordpress.org/hoffkids/) October 29, 2023

10-30-23 I do not how this thing does it, but it just solved my problem that was
bothering me for weeks and my hosting co could not help. I added this plugin (did
not even need to change a setting) and now my changes show up on websites especially
the CSS. thank you so much- you are so helpful and what you created is valuable!!!

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

### 󠀁[O unico que funciona!](https://wordpress.org/support/topic/o-unico-que-funciona/)󠁿

 [mdknet](https://profiles.wordpress.org/mdknet/) March 14, 2023

Fui obrigado a logar no forum para avaliar, é o unico plugin que realmente limpa
o css e js, sempre que preciso estou aqui instalando

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

### 󠀁[Lifesaver – will now use for all dev work](https://wordpress.org/support/topic/lifesaver-will-now-use-for-all-dev-work/)󠁿

 [mrsminkie](https://profiles.wordpress.org/mrsminkie/) February 27, 2023

I found this plugin while searching for a way to prevent CSS files from caching 
while working with a particularly annoying theme (A****). This works perfectly and
I will use it on every website I’m developing from this point forwards. Thank you!

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

### 󠀁[Super Awesome](https://wordpress.org/support/topic/super-awesome-62/)󠁿

 [dklsd787s6](https://profiles.wordpress.org/dklsd787s6/) April 23, 2022

Finally a working plugin, which solves the annoying issue of browsers caching old
versions of a page!

 [ Read all 28 reviews ](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/)

## Contributors & Developers

“Prevent Browser Caching” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ kostyatereshchuk ](https://profiles.wordpress.org/kostyatereshchuk/)

“Prevent Browser Caching” has been translated into 7 locales. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/prevent-browser-caching/contributors)
for their contributions.

[Translate “Prevent Browser Caching” into your language.](https://translate.wordpress.org/projects/wp-plugins/prevent-browser-caching)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/prevent-browser-caching/),
check out the [SVN repository](https://plugins.svn.wordpress.org/prevent-browser-caching/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/prevent-browser-caching/)
by [RSS](https://plugins.trac.wordpress.org/log/prevent-browser-caching/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 3.1.0

 * New: “Update versions” can now also clear the page cache when one of the supported
   caching plugins is active — WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super
   Cache, WP Fastest Cache, WP-Optimize, Breeze, Cache Enabler, Hummingbird, SiteGround
   Optimizer, Swift Performance, Comet Cache. Fixes “I updated the versions, but
   visitors still got the old design from the page cache”. Opt-in: a settings checkbox
   turns it on (off by default — another plugin’s cache is only touched when you
   say so). Each plugin is purged through its own public API; every call is guarded,
   and the version update always completes even if a purge fails.
 * New: after every “Update versions” click the plugin reports what happened — which
   asset types got new versions (per your settings) and whether the detected page
   cache was cleared. The report shows inline on the settings page and as a one-
   time notice after using the toolbar button.
 * New: WP-CLI support — `wp pbc update [--skip-purge]` and `wp pbc status [--format
   =table|json|yaml]`.
 * New: on WordPress 6.9+ the plugin registers two Abilities for AI agents and automation,`
   prevent-browser-caching/bump-versions` and `prevent-browser-caching/status` (
   Abilities API / REST / MCP adapter; require the `manage_options` capability).
 * New for developers: the `pbc_purge_page_cache` filter (veto the purge) and the`
   pbc_after_bump` action (observe every version update and its purge outcome).
 * Fixed: image URLs inside RSS feeds no longer get a “ver” parameter.
 * Fixed: an existing “ver” query parameter in image URLs is now detected precisely—
   a “ver=” fragment inside another parameter name no longer counts as one.
 * Housekeeping: uninstall on multisite now cleans up networks with more than 100
   sites.

#### 3.0.0

 * New automatic mode (now the recommended default): the assets version is taken
   from the file modification time, so browser caching works at full strength and
   busts exactly when a file changes.
 * External URLs (payment scripts, CDNs) are no longer versioned by default — this
   used to break PayPal/Braintree/Authorize.net checkouts. A checkbox brings external
   versioning back; sites upgrading with saved settings keep their previous behavior
   until they switch.
 * New: image cache busting. Attachment URLs are versioned; editing or replacing
   a media file busts its cache.
 * New: HTML page freshness — optional Cache-Control header asking browsers to revalidate
   pages, plus a back/forward-cache guard for stale pages on mobile. Steps aside
   automatically when a page-cache plugin is detected.
 * New: exclusions list (URL substrings or script/style handles) and `pbc_skip_src`/`
   pbc_assets_version` filters for developers.
 * New: optional cache busting in the admin area.
 * New settings screen: a few clear switches, details unfold when you need them.
   Sites upgrading from 2.x get a one-click “Enable recommended settings” banner(
   reversible).
 * The toolbar button is now called “Update versions”: it updates the versions of
   CSS/JS files and images.
 * After activation the plugin opens its settings page.
 * Full backward compatibility: the `prevent_browser_caching()` function, all 2.
   x options and the filter timing work exactly as before.
 * Recommended for developers: use the `pbc_assets_version` filter instead of the`
   prevent_browser_caching()` function — unlike a bare function call, it never causes
   a fatal error if the plugin is deactivated.
 * Fixed: PHP warning “Cannot modify header information” when another plugin printed
   output before the cookie was set.
 * Fixed: the manual update button on the settings page submitted the whole form.
 * Housekeeping: uninstall now removes all plugin options (multisite-aware); all
   strings are translatable; added a POT file; direct-access guards on all files.
 * Raised the minimum PHP version to 7.2 (matches the WordPress minimum). Tested
   on PHP up to 8.5.

#### 2.3.7

 * Fixed a bug with URLs that contain repeated query params: only the last one survived
   after adding the “ver” param. For example, Google Fonts URLs with several “family”
   params lost all font families except the last one.
 * Tested the plugin in WordPress 7.0.
 * Declared the minimum required PHP version (5.6).

#### 2.3.6

 * Tested the plugin in WordPress 6.9.

#### 2.3.5

 * Tested the plugin in WordPress 6.5.

#### 2.3.4

 * Tested the plugin in WordPress 6.1.

#### 2.3.3

 * Tested the plugin in WordPress 6.0.

#### 2.3.2

 * Fixed “Update CSS/JS” button in the admin bar.

#### 2.3.1

 * Tested the plugin in WordPress 5.1.

#### 2.3

 * Tested the plugin in WordPress 5.0-beta1 and optimized the code.

#### 2.2

 * Added function “prevent_browser_caching” which disables all admin settings of
   this plugin and allows to set the new settings.
 * Changing “ver” param instead of adding additional “time” param.

#### 2.1

 * Added option to show “Update CSS/JS” button on the toolbar.

#### 2.0

 * Added setting page to the admin panel.
 * Added automatically updating CSS and JS files every period for individual user
 * Added manually updating CSS and JS files for all site visitors

#### 1.1

 * Added plugin text domain.

#### 1.0

 * First version of Prevent Browser Caching plugin.

## Meta

 *  Version **3.1.0**
 *  Last updated **1 day ago**
 *  Active installations **10.000+**
 *  WordPress version ** 4.7 or higher **
 *  Tested up to **7.0**
 *  PHP version ** 7.2 or higher **
 *  Languages
 * [Catalan](https://ca.wordpress.org/plugins/prevent-browser-caching/), [English (US)](https://wordpress.org/plugins/prevent-browser-caching/),
   [Spanish (Chile)](https://cl.wordpress.org/plugins/prevent-browser-caching/),
   [Spanish (Colombia)](https://es-co.wordpress.org/plugins/prevent-browser-caching/),
   [Spanish (Ecuador)](https://es-ec.wordpress.org/plugins/prevent-browser-caching/),
   [Spanish (Mexico)](https://es-mx.wordpress.org/plugins/prevent-browser-caching/),
   [Spanish (Spain)](https://es.wordpress.org/plugins/prevent-browser-caching/),
   and [Spanish (Venezuela)](https://ve.wordpress.org/plugins/prevent-browser-caching/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/prevent-browser-caching)
 * Tags
 * [browser cache](https://vec.wordpress.org/plugins/tags/browser-cache/)[cache](https://vec.wordpress.org/plugins/tags/cache/)
   [cache busting](https://vec.wordpress.org/plugins/tags/cache-busting/)[clear cache](https://vec.wordpress.org/plugins/tags/clear-cache/)
   [versioning](https://vec.wordpress.org/plugins/tags/versioning/)
 *  [Advanced View](https://vec.wordpress.org/plugins/prevent-browser-caching/advanced/)

## Ratings

 4.9 out of 5 stars.

 *  [  27 5-star reviews     ](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/?filter=4)
 *  [  1 3-star review     ](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/prevent-browser-caching/reviews/)

## Contributors

 *   [ kostyatereshchuk ](https://profiles.wordpress.org/kostyatereshchuk/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/prevent-browser-caching/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://tutori.org/donate/)