suhype / craft-pagecache
Simple HTML Page Cache Plugin
Installs: 224
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- php: ^8.0.2|^9.0
- craftcms/cms: ^4.0.0
- dev-main
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-beta.8
- 1.0.0-beta.7
- 1.0.0-beta.6
- 1.0.0-beta.5
- 1.0.0-beta.4
- 1.0.0-beta.3
- 1.0.0-beta.2
- 1.0.0-beta.1
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- 0.0.1-beta.11
- 0.0.1-beta.10
- 0.0.1-beta.9
- 0.0.1-beta.8
- 0.0.1-beta.7
- 0.0.1-beta.6
- 0.0.1-beta.5
- 0.0.1-beta.4
- 0.0.1-beta.3
- 0.0.1-beta.1
- dev-craftcms-3.x
This package is auto-updated.
Last update: 2024-06-16 18:07:13 UTC
README
Page Cache plugin for Craft CMS 4.x
Simple but useful Page Cache Plugin.
With this plugin you can create static HTML files of your entries.
Requirements
This plugin requires Craft CMS 4.x.
Installation
To install the plugin, follow these instructions.
- Open your terminal and go to your Craft project:
cd /path/to/project
- Then tell Composer to load the plugin:
composer require suhype/craft-pagecache
- In the Control Panel, go to Settings → Plugins and click the “Install” button for Page Cache.
Page Cache Overview
Page Cache is a Craft CMS plugin which can create static HTML files of your entries.
Configuring Page Cache
Go to Settings → Page Cache to setup the basic configuration options:
- Enabled caching: Enable or disable the caching. Note: you need to delete the cache manually.
- Optimize HTML: Minify and optimize HTML. Use with caution!
- Enable gzip compression: Serve gzip compressed cached files.
- Enable brotli compression: Serve brotli compressed cached files. Only works if the PHP brotli extension is installed.
- When globals are saved: Choose what happens when globals got saved. Choose between "Renew cache", "Recreate cache (delete query)", "Delete cache"
- Excluded URL's: Define URL's which should not be cached (regex possible).
- Cache folder path: Define a custom path, where cached files should be stored. Aliases (like
@webroot
) allowed.
Add rewrite rules rules
To speed up your page even more you can add rewrite rules for .htaccess, nginx and apache. You can use the examples for .htaccess (with and without gzip/brotli compression):
- resources/rewrite-rules/.htaccess.example
- resources/rewrite-rules/.htaccess.example.br
- resources/rewrite-rules/.htaccess.example.gzip
The brotli and gzip compressions can be used together, separately or not at all. Just make sure to add them before the normal rewrite rules
Using Page Cache
- Go to Settings → Page Cache
- Enable caching and optionally customize the settings
- As soon as a user visits a page, it got's cached.
- Optional: go to Entries, mark all cachable entries (→ entries with URL's), and Choose Create/Renew cache
Delete Page Caches
- Go to Utilities → Caches
- Select Page Cache
- Click on Clear caches
Console commands
Clear the whole page cache (this is the same as under Utilities):
php craft clear-caches/pagecache
Recreate existing page caches:
# Run `php craft pagecache/recreate --help` to see the possible arguments
php craft pagecache/recreate
Page Cache Roadmap
Some things to do, and ideas for potential features:
- Add entry action to exclude entries
- Add config option to include URL's
Brought to you by Benjamin Ammann