PHPackages                             lewiscom/presto - 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. lewiscom/presto

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

lewiscom/presto
===============

A static cache plugin for Craft CMS 3.x

1.0.0-rc.11(4y ago)166321[2 issues](https://github.com/lewiscommunications/craft-presto/issues)MITPHP

Since May 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lewiscommunications/craft-presto)[ Packagist](https://packagist.org/packages/lewiscom/presto)[ RSS](/packages/lewiscom-presto/feed)WikiDiscussions master Synced 3d ago

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

[![Presto](https://camo.githubusercontent.com/7604deed90bd1a5498aaad4687576714705019fca5aa0dd952bed708373f771a/68747470733a2f2f7777772e6361646469732e636f2f696e7465726e616c2f7265706f2f70726573746f2e737667)](https://camo.githubusercontent.com/7604deed90bd1a5498aaad4687576714705019fca5aa0dd952bed708373f771a/68747470733a2f2f7777772e6361646469732e636f2f696e7465726e616c2f7265706f2f70726573746f2e737667)

Presto is a static file extension for the native [Craft cache](https://docs.craftcms.com/v3/templating/tags/cache.html). It works alongside standard Twig `{% cache %}` tag pairs and includes cache-busting features. Just like standard caching, Presto is automatic. Simply install, update your layouts, and then the cache will bust automatically as you create, update, or delete content.

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

[](#requirements)

This plugin requires Craft CMS 3.0.0 or later.

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

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to load the plugin:

    ```
     composer require lewiscom/presto

    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Presto.

Setup Guide
-----------

[](#setup-guide)

### Step 1 - Turn off element query caching

[](#step-1----turn-off-element-query-caching)

Turn off [element query caching](https://docs.craftcms.com/v3/config/config-settings.html#cacheelementqueries) in your general config file. This will stop the `DeleteStaleTemplateCaches` task from running in the admin. Since Presto busts the entire cache when a new element is saved, element query caching is not necessary.

```
'cacheElementQueries' => false
```

### Step 2 - Add cache tags

[](#step-2---add-cache-tags)

Presto lets Craft do the heavy lifting of calculating the elements within the template. As a result, all you need to do in your templates is pass the cache key returned from `craft.presto.cache` to the native cache tag pair. Presto will return a cache key that includes the host, group (if one is set), and path.

Note that the *entirety* of your template logic *must* be wrapped by the `cache` tags. In addition, it is recommended that you add the `globally` tag so that Craft does not overload the cache (i.e. query string requests).

```
{% cache globally using key craft.presto.cache %}
	{# Template Logic #}
{% endcache %}
```

### Parameters

[](#parameters)

```
{% craft.presto.cache({
	group: 'pjax',
	static: false
}) %}
```

ParameterTypeDescriptiongroupstringWhen set, the requested page will write into a sub-folder within the top-level cache directory. This is useful for pjax implementations where you load a separate template.staticbooleanSetting to false will disable static caching for the request and fall back to native caching logic. The cache key will still be returned, but a static file won't be written.### Step 3 - Configure your server

[](#step-3---configure-your-server)

Your host needs to check for matching static files before Craft handles the request. If the file exists, it's served statically. This block should typically be set immediately preceding the primary Craft "index.php" rewrite. Use these examples as a general guideline, your implementation may vary.

#### Apache

[](#apache)

```
# Check Presto cache
RewriteCond %{REQUEST_FILENAME} !\.(css|eot|gif|ico|jpe?g|otf|png|svg|ttf|webp|woff2?)$ [NC]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/presto%{REQUEST_URI}/index.html -f
RewriteRule .* /cache/%{HTTP_HOST}/presto%{REQUEST_URI}/index.html [L,E=nocache:1]]

# Craft rewrite here
```

If you add a cache group, you'll need to add additional configuration. Below is an example of a pjax implementation:

```
RewriteCond %{REQUEST_FILENAME} !\.(css|eot|gif|ico|jpe?g|otf|png|svg|ttf|webp|woff2?)$ [NC]
RewriteCond %{HTTP:X-PJAX} true
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cache/%{HTTP_HOST}/presto/pjax%{REQUEST_URI}/index.html -f
RewriteRule .* /cache/%{HTTP_HOST}/presto/pjax%{REQUEST_URI}/index.html [L,E=nocache:1]]
```

#### Nginx

[](#nginx)

```
# Block direct cache access
location /cache {
	internal;
}

# Check Presto cache
location ~ !\.(css|gif|ico|jpe?g|png|svg)$ {
	if ($request_method = GET) {
		try_files $uri /cache/$http_host/presto/$uri/index.html;
	}
}

# Craft rewrite here
```

Disable Caching
---------------

[](#disable-caching)

### Multi-enviroment

[](#multi-enviroment)

If you use a [multi-environment config](https://craftcms.com/docs/multi-environment-configs), set an arbitrary cache variable in your general config. Override this variable on environments where you don't want static caching (e.g. local development).

**General Config Variable**

```
`cacheEnabled` => true
```

**Cache Tag**

```
{% cache globally using key craft.presto.cache if conf.cacheEnabled is defined and conf.cacheEnabled %}
	{# Template Logic #}
{% endcache %}
```

### Individual Templates

[](#individual-templates)

When using Presto the `for`, `until`, `if`, and `unless` parameters won't be respected on each request once the static html file is created. To disable the cache on individual templates, set a variable on the main cache tag. Override that variable on each template where you don't want static caching.

**Cache Tag**

```
{% cache globally using key craft.presto.cache if cacheEnabled is defined ? cacheEnabled : true %}

            {{ block('content') }}

{% endcache %}
```

**Cache Template Override**

```
{% extends '[layout-template-path]' %}

{# Disable caching on this page #}
{% set cacheEnabled = false %}

{% block content %}
	{# page content #}
{% endblock %}
```

Directory Structure
-------------------

[](#directory-structure)

Presto resolves subdomain hosts automatically. Static html files are created inside a directory named after the requested host (i.e. coolwebsite.com, sub.coolwebsite.com). An additional directory called "presto" is created inside each host directory to avoid .htaccess filename conflicts. See below for an example cache file directory structure:

```
- cache
	- coolwebsite.com
		- presto
			- index.html
			- blog
				- index.html

```

Purging the Cache
-----------------

[](#purging-the-cache)

To purge the cache, navigate to the Presto plugin settings page (*Settings &gt; Presto*) and click "Purge Cache" ([immediate](#immediate-purge)) or "Schedule Purge" ([cron](#cron-purge)).

[![presto-settings](presto-settings.jpg?raw=true "Presto Settings")](presto-settings.jpg?raw=true)

**Note:** The Cron purge method does not clear the template cache. Remember to [purge the template cache](https://craftcms.com/docs/templating/cache#cache-clearing) before you schedule a purge.

Purge Method
------------

[](#purge-method)

Presto provides two purge methods: immediate and cron.

### Immediate Purge

[](#immediate-purge)

By default, Presto will purge the static cache and all related Craft template caches immediately. This only occurs in the server instance where the cache was cleared.

### Cron Purge

[](#cron-purge)

If you run Presto in an environment that spins up multiple server instances, set the [purgeMethod config](#config) to "cron". Set up a cron job on each server instance that runs the `presto/default/check` console command. The following example will run it every 10 minutes.

```
*/10 * * * *  php /var/www/craft presto/default/check
```

Disabled/Archived Entries
-------------------------

[](#disabledarchived-entries)

If an entry exists in the CMS but is not displayed on the site (e.g. status is disabled, entry is archived, etc.), enabling the entry will not clear any caches. Presto only clears related entries that are displayed on the site. In order to display your newly enabled entry, [purge the entire cache](#purging-the-cache).

Events
------

[](#events)

Presto comes with a couple of events should you need them.

The following events will emit a `CacheEvent` event handler with the following properties

- `html` - the generated HTML
- `cacheKey` - the cache key
- `filePath` - the file path that the static file will be saved
- `host` - the hostname
- `path` - the url segment path
- `config` - any configuration passed from the `PrestoVariable`

```
Presto::EVENT_BEFORE_GENERATE_CACHE_ITEM
```

```
Presto::EVENT_AFTER_GENERATE_CACHE_ITEM
```

The following events will emit a `PurgeEVent` event with the following parameters:

- `cacheKey` - an array of cache keys that were purged

```
Presto::EVENT_BEFORE_PURGE_CACHE
```

```
Presto::AFTER_BEFORE_PURGE_CACHE
```

```
Presto::EVENT_BEFORE_PURGE_CACHE_ALL
```

```
Presto::AFTER_BEFORE_PURGE_CACHE_ALL
```

**Note:** the purge all events *will not* pass through the cache keys

Roadmap
-------

[](#roadmap)

- Display a list of cached pages in the admin
- Add ability to clear individual cached pages in the admin
- Warm cache after an entry is saved or created

License
-------

[](#license)

Copyright 2017 [Lewis Communications, LLC](http://www.lewiscommunications.com). Licensed under the [Apache License, Version 2.0](LICENSE).

Brought to you by [Lewis Communications](https://www.lewiscommunications.com)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55% 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 ~60 days

Recently: every ~167 days

Total

20

Last Release

1764d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e693e4f109f2ea6cc56b22a955b7b47501721f802bfde6482248384599202599?d=identicon)[lewiscommunications](/maintainers/lewiscommunications)

---

Top Contributors

[![leigeber](https://avatars.githubusercontent.com/u/255097?v=4)](https://github.com/leigeber "leigeber (11 commits)")[![paynerb](https://avatars.githubusercontent.com/u/12212345?v=4)](https://github.com/paynerb "paynerb (6 commits)")[![Ticolyle](https://avatars.githubusercontent.com/u/2542219?v=4)](https://github.com/Ticolyle "Ticolyle (3 commits)")

---

Tags

cmsCraftcraftcmscraft-pluginpresto

### Embed Badge

![Health badge](/badges/lewiscom-presto/health.svg)

```
[![Health](https://phpackages.com/badges/lewiscom-presto/health.svg)](https://phpackages.com/packages/lewiscom-presto)
```

###  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)

PHPackages © 2026

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