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.5k↓72.2%2MITPHP

Since Jan 9Pushed 1w 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 3.x Synced 2w 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;= 5.0.0
- PHP &gt;= 8.2

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

[](#installation)

### Project

[](#project)

Open your terminal and go to your Craft project:

```
cd /path/to/project
composer require codemonauts/craft-asset-autoversioning
php craft plugin/install 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

46

—

FairBetter than 92% of packages

Maintenance64

Regular maintenance activity

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 56.5% 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

1568d 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 (6 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

[verbb/formie

The most user-friendly forms plugin for Craft.

101400.6k78](/packages/verbb-formie)[verbb/hyper

A user-friendly links field for Craft.

24153.5k14](/packages/verbb-hyper)[verbb/vizy

A flexible visual editor field for Craft.

4251.5k1](/packages/verbb-vizy)[verbb/events

A full-featured plugin for event management and ticketing.

2312.1k](/packages/verbb-events)[mmikkel/cache-flag

Cold template caches that can be flagged and automatically invalidated.

1730.6k1](/packages/mmikkel-cache-flag)

PHPackages © 2026

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