Skip to content

Allows you to keep an aggressive cache policy with your HTTP server while using flask.

License

Notifications You must be signed in to change notification settings

italomaia/flask-rev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

travis status

Flask-Rev

Flask-Rev is a very simple flask extension that aims to make it easier to integrate flask and those fancy reactive javascript front-ends out there (react, angular, vuejs...). It allows you to keep an aggressive cache with your HTTP server AND always return fresh static content to user requests. It does so by appending the static file hash to the static file's url as a query string parameter.

Notice that appending the hash only happens when debug mode is False. Also, be aware that the hash cache is created during runtime. So, you may experience some "warming up" slow-down in the first request. This behavior might change in the future.

The advantage of this approach? Your static files names won't change between updates.

This plugin is heavely based upon these two snippets:

Thanks!

Installation

pip install flask-rev

Usage

from flask import Flask, url_for
from flask_rev import Rev

app = Flask(__name__)
Rev(app)

url_for('static', filename='bundle.js')
# outputs: /static/bundle.js?h=<md5hash>

Running Tests

> python3 setup.py test
> # or
> tox

About

Allows you to keep an aggressive cache policy with your HTTP server while using flask.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published