PHPackages                             codemonauts/craft-asset-autoversioning - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. codemonauts/craft-asset-autoversioning

ActiveCraft-plugin[Caching](/categories/caching)

codemonauts/craft-asset-autoversioning
======================================

A Twig extension for Craft CMS that helps you cache-bust your assets.

2.0.0(4y ago)418.1k—0%2[2 issues](https://github.com/codemonauts/craft-asset-autoversioning/issues)MITPHP

Since Jan 9Pushed 4y ago3 watchersCompare

[ Source](https://github.com/codemonauts/craft-asset-autoversioning)[ Packagist](https://packagist.org/packages/codemonauts/craft-asset-autoversioning)[ RSS](/packages/codemonauts-craft-asset-autoversioning/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (4)Used By (0)

Assets Autoversioning plugin for Craft CMS
==========================================

[](#assets-autoversioning-plugin-for-craft-cms)

[![Icon](resources/autoversioning.png)](resources/autoversioning.png)

A really basic Twig extension for CraftCMS that helps you cache-bust your assets.

Background
----------

[](#background)

To force the browser to download the new asset file after a update, the plugin allows you to add a Twig function, which adds the build number or the filemtime to the filename.

Requirements
------------

[](#requirements)

- Craft CMS &gt;= 4.0.0

Installation
------------

[](#installation)

### Project

[](#project)

Open your terminal and go to your Craft project:

```
cd /path/to/project
composer require codemonauts/craft-asset-autoversioning
./craft install/plugin craft3-assets-autoversioning
```

### CI/CD Pipeine

[](#cicd-pipeine)

The build number which gets added to the asset URL is read from a file called `build.txt` which must exist in your project folder. Use for example something like this in your deployment script (Example is for CodeShip):

```
echo -n "${CI_BUILD_NUMBER}" > build.txt
```

If the file doesn't exists, the filemtime of the asset is used.

### Webserver

[](#webserver)

Because the clients will from now on start to request files like `/css/styles.12345678.css` we need to tell the webserver how to rewrite these URLs so that the original `/css/styles.css` will get served.

**Apache**

```

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*?\/)*?([a-z\.\-]+)(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1$2$4 [L]

```

**NGINX**

```
location ~* (.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif|webp)$ {
  try_files $uri $1.$2;
}
```

Usage
-----

[](#usage)

Use the new Twig function `versioning()` in your template. For example in pug:

```

```

will result in something like this:

```

```

With ❤ by [codemonauts](https://codemonauts.com)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 59.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~605 days

Total

3

Last Release

1476d ago

Major Versions

1.0.3 → 2.0.02022-05-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/539161?v=4)[codemonauts](/maintainers/codemonauts)[@codemonauts](https://github.com/codemonauts)

---

Top Contributors

[![Bruellmuecke112](https://avatars.githubusercontent.com/u/20341175?v=4)](https://github.com/Bruellmuecke112 "Bruellmuecke112 (13 commits)")[![kringkaste](https://avatars.githubusercontent.com/u/964698?v=4)](https://github.com/kringkaste "kringkaste (5 commits)")[![fleaz](https://avatars.githubusercontent.com/u/2489598?v=4)](https://github.com/fleaz "fleaz (2 commits)")[![sbstnrch](https://avatars.githubusercontent.com/u/9051884?v=4)](https://github.com/sbstnrch "sbstnrch (2 commits)")

---

Tags

cache-bustcachingcmscraftcraftcmsplugincachecmsassetsCraftcraftcmscraft-plugin

### Embed Badge

![Health badge](/badges/codemonauts-craft-asset-autoversioning/health.svg)

```
[![Health](https://phpackages.com/badges/codemonauts-craft-asset-autoversioning/health.svg)](https://phpackages.com/packages/codemonauts-craft-asset-autoversioning)
```

###  Alternatives

[nystudio107/craft-fastcgicachebust

Bust the Nginx FastCGI Cache when entries are saved or created.

1953.5k3](/packages/nystudio107-craft-fastcgicachebust)[mmikkel/cache-flag

Cold template caches that can be flagged and automatically invalidated.

1729.9k1](/packages/mmikkel-cache-flag)[bolden/htmlcache

Cache pages to HTML and boost website performance on Craft CMS 3.

317.9k](/packages/bolden-htmlcache)[saccilottoconsulting/craft-internal-assets

A simple plugin to restrict access to assets for permitted users only. Access to a given asset is only granted if the user has view-permissions for the given source (this can be set in the user- or group-settings). The asset source folder should be moved out of the web root folder so the files are never accessible without this plugin.

353.5k](/packages/saccilottoconsulting-craft-internal-assets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
