Optimize Datasette performance behind a caching proxy
Project description
datasette-hashed-urls
Optimize Datasette performance behind a caching proxy
This plugin provides an alternative for Datasette's deprecated Hashed URL mode.
Installation
Install this plugin in the same environment as Datasette.
$ datasette install datasette-hashed-urls
Usage
Once installed, this plugin will act on any immutable database files that are loaded into Datasette:
datasette -i fixtures.db
The database will automatically be renamed to incorporate a hash of the contents of the SQLite file - so the above database would be served as:
http://127.0.0.1:8001/fixtures_aa7318b
Every page that accesss that databasae, including JSON endpoints, will be served with a far-future cache expiry header.
A caching proxy such as Cloudflare can then be used to cache and accelerate content served by Datasette.
When the database file is updated and the server is restarted, the hash will change and content will be served from a new URL. Any hits to the previous hashed URLs will be automatically redirected.
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-hashed-urls
python3 -mvenv venv
source venv/bin/activate
Or if you are using pipenv
:
pipenv shell
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file datasette-hashed-urls-0.1a0.tar.gz
.
File metadata
- Download URL: datasette-hashed-urls-0.1a0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10cc9a31ea28664a19fe2667a0b5aa2636cb72ed6800174e3b885021c3ad42dc |
|
MD5 | a77441856be6ee602b18646c477cb22e |
|
BLAKE2b-256 | c6a923582aca7cc52b8c8609fbe7fff46991abf727bf7ab4854d78b5bcff477d |
File details
Details for the file datasette_hashed_urls-0.1a0-py3-none-any.whl
.
File metadata
- Download URL: datasette_hashed_urls-0.1a0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d8c29e8e0bd66d53e48640425877cf5a3d2e4a5a18a7f8c5a9ec2cdda352b08 |
|
MD5 | f8c7fd271db99f97e15e68cd5c987756 |
|
BLAKE2b-256 | 2fbe740ee11d87081ba90b304ab2f078a687780e8409704fe982b4d542dec500 |