Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/italomaia/flask-rev
Allows you to keep an aggressive cache policy with your HTTP server while using flask.
https://github.com/italomaia/flask-rev
files flask hash python static
Last synced: 28 days ago
JSON representation
Allows you to keep an aggressive cache policy with your HTTP server while using flask.
- Host: GitHub
- URL: https://github.com/italomaia/flask-rev
- Owner: italomaia
- License: other
- Created: 2016-08-01T14:14:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-14T23:08:24.000Z (almost 5 years ago)
- Last Synced: 2024-09-27T09:09:01.853Z (about 1 month ago)
- Topics: files, flask, hash, python, static
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![travis status](https://travis-ci.org/italomaia/flask-rev.svg?branch=master)
# 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:
* https://gist.github.com/mfenniak/2978805
* https://gist.github.com/Ostrovski/f16779933ceee3a9d181#file-flask_static_files_cache_invalidator-py-L20Thanks!
## Installation
pip install flask-rev
## Usage
```py
from flask import Flask, url_for
from flask_rev import Revapp = Flask(__name__)
Rev(app)url_for('static', filename='bundle.js')
# outputs: /static/bundle.js?h=
```## Running Tests
```bash
> python3 setup.py test
> # or
> tox
```