PHPackages                             sylvainallignol/cache-stamp - 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. sylvainallignol/cache-stamp

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

sylvainallignol/cache-stamp
===========================

Cache buster for CSS, JS, fonts, SVG, PDF and images with advanced configuration options

1.0.4(3mo ago)941MITPHPPHP &gt;=8.2

Since Feb 10Pushed 3mo agoCompare

[ Source](https://github.com/SylvainAllignol/kirby-cache-stamp)[ Packagist](https://packagist.org/packages/sylvainallignol/cache-stamp)[ Docs](https://plugins.getkirby.com/sylvainallignol/cache-stamp)[ RSS](/packages/sylvainallignol-cache-stamp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

Kirby Cache Stamp
=================

[](#kirby-cache-stamp)

A simple and lightweight Kirby plugin to handle **cache busting for CSS, JS, fonts, SVG, PDF and images** with advanced configuration options.

Features
--------

[](#features)

- Automatic cache busting for CSS, JS, fonts, SVG, PDF and images
- Multiple hash methods (MD5, SHA1, SHA256, XXH3, Timestamp)
- Customizable hash prefix and suffix
- Helpers and field methods
- Supports both relative and absolute URLs

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

[](#requirements)

- Kirby CMS: 3x, 4.x, or 5.x
- PHP 8.2 or superior

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

[](#installation)

### Via Composer (recommended)

[](#via-composer-recommended)

```
composer require sylvainallignol/cache-stamp
```

### Manual (ZIP)

[](#manual-zip)

1. Download the latest release ZIP from GitHub
2. Unzip into `site/plugins/kirby-cache-stamp`

### Apache (.htaccess)

[](#apache-htaccess)

Add the following rules to the .htaccess file at the root of your site:

```
# --------------------------------------------------------
# Cache busting for CSS, JS, fonts, SVG, PDF and images
# --------------------------------------------------------

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.([a-zA-Z0-9]+)\.(css|js|woff2?|ttf|svg|pdf|jpe?g|png|gif|webp|avif)$ $1.$3 [L,NC]
```

### Nginx (example)

[](#nginx-example)

```
location ~* ^/(.+)\.[a-zA-Z0-9]+\.(css|js|woff2?|ttf|svg|pdf|jpe?g|png|gif|webp|avif)$ {
    try_files /$1.$2 $uri =404;
}
```

Configuration
-------------

[](#configuration)

Add options to your `config.php`:

```
return [
    'sylvainallignol.cache-stamp' => [
        'active' => true,          // Enable/disable the plugin
        'method' => 'xxh3',        // Hash method: md5, sha1, sha256, xxh3, timestamp
        'prefix' => '',            // Prefix before the hash (a-z, A-Z, 0-9, -, _)
        'suffix' => ''             // Suffix after the hash (a-z, A-Z, 0-9, -, _)
    ]
];
```

### Available Hash Methods

[](#available-hash-methods)

All hash methods use the file's **modification timestamp** as their source. The hash obscures the actual modification date for security reasons while still ensuring the URL changes when the file is updated.

- **xxh3** (default): Fast and efficient hash algorithm - produces a 16-character hash from the timestamp
- **md5**: MD5 hash - produces a 32-character hash from the timestamp
- **sha1**: SHA1 hash - produces a 40-character hash from the timestamp
- **sha256**: SHA256 hash - produces a 64-character hash from the timestamp
- **timestamp**: Direct file modification timestamp - uses the raw timestamp (not recommended for production as it exposes modification dates)

**Note:** If the file doesn't exist or its modification time cannot be determined, the plugin returns the original URL unchanged (no cache busting applied).

### Supported File Types

[](#supported-file-types)

The plugin automatically processes these file types:

- **css** - Stylesheets
- **js** - JavaScript files
- **woff, woff2** - Web fonts
- **ttf** - TrueType fonts
- **svg** - SVG files
- **pdf** - PDF documents
- **jpg, jpeg** - JPEG images
- **png** - PNG images
- **gif** - GIF images
- **webp** - WebP images
- **avif** - AVIF images

Usage
-----

[](#usage)

### Automatic (Components)

[](#automatic-components)

The plugin automatically handles `css()` and `js()` helpers:

```
