PHPackages                             cooltronicpl/craft-files-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. [Templating &amp; Views](/categories/templating)
4. /
5. cooltronicpl/craft-files-autoversioning

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

cooltronicpl/craft-files-autoversioning
=======================================

A simple yet powerful Twig extension for CraftCMS. It assists in cache-busting your assets, ensuring that users always receive the latest versions of your files.

2.2.0(2y ago)4871GPL-3.0-or-laterPHP

Since Mar 21Pushed 2y ago1 watchersCompare

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

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

Static Files Autoversioning Plugin for Craft CMS
================================================

[](#static-files-autoversioning-plugin-for-craft-cms)

This plugin is a Twig extension that helps you cache-bust your static assets, such as CSS, JS, images, videos, or PDFs. It appends a version number to the asset URL, based on either a build number or the file’s last modified time. This ensures that your users always receive the most recent version of your files, without having to clear their browser cache.

   ![Static Files Autoversioning Plugin for Craft CMS](resources/white.png)Table of Contents
-----------------

[](#table-of-contents)

1. [Features](#features)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Advanced Usage](#advanced-usage)
    - [Versioning from a String](#versioning-from-a-string)
    - [Versioning from a Timestamp](#versioning-from-a-timestamp)
    - [Versioning from a Custom Text File](#versioning-from-a-custom-text-file)
    - [Versioning with PDF Generator or Varnish Cache](#versioning-with-pdf-generator-or-varnish-cache)
    - [Note about paths](#note-about-paths)
5. [License](#license)
6. [Credits](#credits)

Features
--------

[](#features)

- Compatible with Craft CMS 3.x, 4.x and 5.0.0.alpha
- Supports multiple file types and caching policies
- Allows custom versioning from strings or text files
- Integrates with PDF Generator and Varnish Cache plugins

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

[](#installation)

You can install this plugin from the [Craft Plugin Store](https://plugins.craftcms.com/craft3-files-autoversioning) or with Composer.

### From the Plugin Store

[](#from-the-plugin-store)

Go to the Plugin Store section of your Craft control panel and search for “Static Files Autoversioning”. Then click on the “Install” button in its modal window.

### Project Setup

[](#project-setup)

To install the plugin, navigate to your Craft project in your terminal:

```
# go to the project directory
cd /path/to/my-project

# tell Composer to load the plugin
composer require cooltronicpl/craft-files-autoversioning

# tell Craft to install the plugin
./craft install/plugin craft3-files-autoversioning
```

Usage
-----

[](#usage)

To use this plugin, you need to call the `version()` function in your template, passing the asset path as an argument. For example:

```

```

This will output something like:

```

```

The version number (`v=12345678`) is determined by reading a file named `build.txt` in your root project folder (alongside `config`, `templates`, etc.). You can create and update this file using your deployment script. For instance, if you’re using CodeShip, you can use the following command:

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

Advanced Usage
--------------

[](#advanced-usage)

### Versioning from a String

[](#versioning-from-a-string)

If you want to use a custom string as the version number, you can use the `versionString()` function, passing the asset path and the string as arguments. For example:

```

```

This will output something like:

```

```

### Versioning from a Timestamp

[](#versioning-from-a-timestamp)

If you want to use the file’s last modified time as the version number, regardless of the existence of the build.txt file, you can use the `versionTimestamp()` function, passing the asset path as an argument. For example:

```

```

This will output something like:

```

```

### Versioning from a Custom Text File

[](#versioning-from-a-custom-text-file)

If you want to use the content of a custom text file as the version number, you can use the `versionCustom()` function, passing the asset path and the text file name as arguments. The text file should be located in your root project folder. For example:

```

```

This will output something like:

```

```

Assuming that the `mods.txt` file contains the word “modded”.

### Versioning with PDF Generator or Varnish Cache

[](#versioning-with-pdf-generator-or-varnish-cache)

You can also use this plugin with [PDF Generator](https://github.com/cooltronicpl/Craft-document-helpers/) when your hosting or server is caching PDF files. Or your files are cached by caching plugins like [Varnish Cache](https://github.com/cooltronicpl/varnishcache/).

```
LINK
```

This will output something like:

```
LINK
```

This generates a PDF with a version number, solving any caching policy issues with your hosting.

### Note about paths

[](#note-about-paths)

By default, the plugin searches for files to version in the `@webroot` directory, and for the `build.txt` or custom text file in the `@root` path.

**Note:** You can learn more about the `@webroot` and `@root` aliases and how to configure them in the Craft CMS documentation.

License
-------

[](#license)

This plugin is licensed under the [GPLv3 license](LICENSE.md).

Credits
-------

[](#credits)

This plugin is brought to you with love by [CoolTRONIC.pl sp. z o.o. (LLC) Interactive Agency](https://cooltronic.pl/) and [Pawel Potacki](https://potacki.com/).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.4% 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 ~253 days

Total

5

Last Release

873d ago

Major Versions

1.0.0 → 2.0.02022-11-12

1.1.0 → 2.1.02023-06-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/8615c6563313b391118ff3733854b99fa6c4f5b44bd3cad6d8f4818fa360433c?d=identicon)[cooltronicpl](/maintainers/cooltronicpl)

---

Top Contributors

[![cooltronicpl](https://avatars.githubusercontent.com/u/35310568?v=4)](https://github.com/cooltronicpl "cooltronicpl (14 commits)")[![potacki-com](https://avatars.githubusercontent.com/u/140613227?v=4)](https://github.com/potacki-com "potacki-com (3 commits)")

---

Tags

static-files-autoversioningcraft-cms-cache-busting-plugintwig-extension-for-asset-versioningcraft-cms-static-asset-optimizationcache-busting-and-versioning-for-craft-cms

### Embed Badge

![Health badge](/badges/cooltronicpl-craft-files-autoversioning/health.svg)

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

###  Alternatives

[nystudio107/craft-templatecomments

Adds a HTML comment with performance timings to demarcate `{% block %}`s and each Twig template that is included or extended.

20108.4k3](/packages/nystudio107-craft-templatecomments)[superbig/craft-mjml

Render Twig emails with MJML, the only framework that makes responsive email easy.

2627.3k1](/packages/superbig-craft-mjml)[verbb/footnotes

Adds a footnotes feature to CKEditor fields and Twig templates.

213.3k](/packages/verbb-footnotes)

PHPackages © 2026

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