joshangell / Falcon

Enables Xkey / Hash-Two / Surrogate Key caching with Craft 2.x. Very experimental.
MIT License
14 stars 0 forks source link
craft-plugin craft2 craftcms experimental varnish

This plugin was an experiment! It is now archived.

I advise you take a look at Upper for Craft 3 by the wonderful Oliver Stark.


Falcon plugin for Craft CMS

Make Craft fly. Well, stick a reverse proxy in front of it then auto-magically invalidate the right caches.

Installation

To install Falcon, follow these steps:

  1. Download & unzip the file and place the falcon directory into your craft/plugins directory
  2. -OR- do a git clone https://github.com/joshangell/falcon.git directly into your craft/plugins folder. You can then update it with git pull
  3. -OR- install with Composer via composer require joshangell/falcon
  4. Install plugin in the Craft Control Panel under Settings > Plugins
  5. The plugin folder should be named falcon for Craft to see it. GitHub recently started appending -master (the branch name) to the name of the folder for zip file downloads.
  6. Copy the code below into craft/app/etc/templating/BaseTemplate.php, inserting it after if ($cacheService) { ... } in the _includeElementInTemplateCaches method:
$falcon = craft()->getComponent('falcon_templates', false);
if ($falcon) {
    $falcon->includeElement($elementId);
}

Yes that was a core hack, which is always necessary on Craft 2.

Falcon works on Craft 2.4.x and Craft 2.5.x.

Falcon Overview

Currently very un-configurable.

The Varnish URL is set to http://0.0.0.0:8080/, the headers used are xkey specific, silly things are happening like Matrix blocks are getting their IDs sent out, there are no Tasks and custom keys aren’t purged.

But hey, this is basically still classed as an experiment.

Configuring Falcon

You need to do this in your layout:

{% falcon %}

<!DOCTYPE html>
<html>
    <head>...</head>
    <body>
        ...
    </body>
</html>
{% endfalcon %}

Then elsewhere:

{% extends "_layout" %}

{% falcon_addkey 'section:news' %}

{% block content %}
...
{% endblock %}

Using Falcon

-Insert text here-

Falcon Roadmap

These things need to happen before it can be considered ready for use:

Brought to you by Josh Angell