Skip to main content

Optimize Datasette performance behind a caching proxy

Project description

datasette-hashed-urls

PyPI Changelog Tests License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette-hashed-urls-0.1a0.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

datasette_hashed_urls-0.1a0-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page