Utilities to help development of sites that utilize Edge Side Includes
Project description
Django application for handling edge side include (ESI)
Usage
ESI allows you to specify sections of the site that require different caching strategies and can be sent to a smart caching layer for rendering.
For example, if you want to send a page that is identical for every user except for a welcome message, you could render that message like:
<html> <body> <esi:include "/esi/welcome-message" /> ... the rest of the page ... </body> </html>
A smart proxy such as Varnish and the middleware included with armstrong.esi can cache this page, and send a request for /esi/welcome-message for personalization. The next user hitting the page would get the cached version and your application server would only need to render /esi/welcome-message
armstrong.esi provides a template tag for rendering the correct urls with the same syntax as django’s url tag. For example, the above example becomes:
{% load esi %} <html> <body> {% esi welcome_message %} ... the rest of the page ... </body> </html>
This replaces our {% esi %} tag with a <esi:include> tag pointing to the URL for that view.
Using with Varnish
Varnish integrates fairly easily with armstrong.esi. The EsiHeaderMiddleware sets the ‘X-ESI’ header to ‘true’ if the page request has esi tags on it. To enable esi processing in varnish for pages that need it, add the following to your vcl_fetch method:
if (beresp.http.X-ESI) { set beresp.do_esi = true; }
Loading without ESI
The template tag reads the DEBUG settings value and if set to True renders the view with the current request rather than including the <esi:include> tag. This makes it easy to see fully rendered pages in development.
Installation & Configuration
You can install the latest release of armstrong.esi using pip:
pip install armstrong.apps.articles
Make sure to add armstrong.esi to your INSTALLED_APPS. You can add this however you like. This works as a copy-and-paste solution:
INSTALLED_APPS += ["armstrong.esi"]
You must also enable the armstrong.esi middleware. To do this, add the following line to your MIDDLEWARE_CLASSES:
'armstrong.esi.middleware.EsiMiddleware'
Contributing
Create something awesome – make the code better, add some functionality, whatever (this is the hardest part).
Create a topic branch to house your changes
Get all of your commits in the new topic branch
Submit a pull request
State of Project
Armstrong is an open-source news platform that is freely available to any organization. It is the result of a collaboration between the Texas Tribune and Bay Citizen, and a grant from the John S. and James L. Knight Foundation. The first release is scheduled for June, 2011.
To follow development, be sure to join the Google Group.
armstrong.apps.articles is part of the Armstrong project. You’re probably looking for that.
License
Copyright 2011-2012 Bay Citizen and Texas Tribune
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file armstrong.esi-1.1.0.tar.gz
.
File metadata
- Download URL: armstrong.esi-1.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c48e7e4c0e749a381b137f4bd39b3c4db8e9c8056d987b9071ba717c29771fc |
|
MD5 | 79ce5fb6b8c1f0f14e2de3a0a7c26372 |
|
BLAKE2b-256 | 0b6d99c2804e96ea76498f1a4470f8f524c6d2de313d8914a62b87c7a539a791 |