Skip to content
Snippets Groups Projects
PROJECTPAGE.md 2.92 KiB
Newer Older
This module queues URLs or paths to your
[Purge](https://www.drupal.org/project/purge) queue.
Niels van Mourik's avatar
Niels van Mourik committed
Drupal 8 introduces tag-based cache invalidation which is much more efficient
than legacy URL or path based invalidation and leads to less processing and
smaller queues. However, when your CDN or external caching system **does not
support tag-based invalidation**, this module is for you!
## How it works
Niels van Mourik's avatar
Niels van Mourik committed
The module trains its _traffic registry_ by collecting URLs from requests that
miss cache inside Drupal's own page cache. These URLs are stored along with
their associated _cache tags_ inside this same _traffic registry_. Now when
Drupal invalidates a set of tags because someone edited a page, these tags are
used to fetch URLs from the registry and are added to the Purge queue.
Niels van Mourik's avatar
Niels van Mourik committed
##### Accuracy
Those that remember [cache expiration](https://www.drupal.org/project/expire)
for Drupal 7 are familiar with the _side effects_ of some changes not
Niels van Mourik's avatar
Niels van Mourik committed
being automatically detected. This module can guarantee very high accuracy since
it simply leverages D8's highly innovative _tags based_ caching architecture,
which is thoroughly covered by tests that cover edge cases most site builders
wouldn't think off. Examples of things that _just work_ are
pagers (``/news/?page=10``), RSS or Json views (``/rss.xml``) and any view or
view block, like that one dynamic block placed on ``/contact`` that shows
corporate press releases.
Niels van Mourik's avatar
Niels van Mourik committed
## Very important warning!
This module isn't suited for everyone and *can bring your site down* if you're
not careful!
Niels van Mourik's avatar
Niels van Mourik committed

Because it stores URLs for all of your traffic, sites with thousands of content
items can end up creating a unsustainable large registry with *database strain*
as ultimate consequence. If you're noticing that queries coming from this module
are severely slowing down your website, the only alternatives you have are:
Niels van Mourik's avatar
Niels van Mourik committed

1. Switch to a CDN that does support tag-based cache invalidation.
2. Stay with the CDN, but:
Niels van Mourik's avatar
Niels van Mourik committed
  * Uninstall and stop using ``purge_queuer_url``.
  * Configure the CDN to override your caching policy at the edge.
  * The override should set a reasonably short cache policy for all
    CDN-to-browser delivery.
Niels van Mourik's avatar
Niels van Mourik committed

## Getting started

* Setup the [Purge module](https://www.drupal.org/project/purge).
* Make sure that your purger(s) support URL or path invalidations.
* ``drush en purge_queuer_url --yes``
* ``drush cset system.performance cache.page.max_age 31536000`` (year)
* ``drush cache-rebuild`` to empty Drupal's page cache.

Niels van Mourik's avatar
Niels van Mourik committed
To achieve accurate URL based cache invalidation, it is best to take a head
start by training the _traffic registry_ that ``purge_queuer_url`` maintains:

```
wget -r -nd --delete-after -l100 --spider http://mydrupalsite/
```
Niels van Mourik's avatar
Niels van Mourik committed

Niels van Mourik's avatar
Niels van Mourik committed
When this process finished, editing any item on your site should result in
several URLs being added to the Purge queue (see ``drush p-queue-browse``).
Ordinary website traffic will automatically add new URLs to your _traffic
registry_ and won't require any further maintenance.