mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
URL hashing is now off by default - closes #418
Prior to this commit Datasette would calculate the content hash of every
database and redirect to a URL containing that hash, like so:
https://v0-27.datasette.io/fixtures => https://v0-27.datasette.io/fixtures-dd88475
This assumed that all databases were opened in immutable mode and were not
expected to change.
This will be changing as a result of #419 - so this commit takes the first step
in implementing that change by changing this default behaviour. Datasette will
now only redirect hash-free URLs under two circumstances:
* The new `hash_urls` config option is set to true (it defaults to false).
* The user passes `?_hash=1` in the URL
This commit is contained in:
parent
afe9aa3ae0
commit
6f6d0ff2b4
15 changed files with 149 additions and 70 deletions
|
|
@ -115,11 +115,21 @@ Enable/disable the ability for users to run custom SQL directly against a databa
|
|||
default_cache_ttl
|
||||
-----------------
|
||||
|
||||
Default HTTP caching max-age header in seconds, used for ``Cache-Control: max-age=X``. Can be over-ridden on a per-request basis using the ``?_ttl=`` querystring parameter. Set this to ``0`` to disable HTTP caching entirely. Defaults to 365 days (31536000 seconds).
|
||||
Default HTTP caching max-age header in seconds, used for ``Cache-Control: max-age=X``. Can be over-ridden on a per-request basis using the ``?_ttl=`` querystring parameter. Set this to ``0`` to disable HTTP caching entirely. Defaults to 5 seconds.
|
||||
|
||||
::
|
||||
|
||||
datasette mydatabase.db --config default_cache_ttl:10
|
||||
datasette mydatabase.db --config default_cache_ttl:60
|
||||
|
||||
default_cache_ttl_hashed
|
||||
------------------------
|
||||
|
||||
Default HTTP caching max-age for responses served using using the :ref:`hashed-urls mechanism <config_hash_urls>`. Defaults to 365 days (31536000 seconds).
|
||||
|
||||
::
|
||||
|
||||
datasette mydatabase.db --config default_cache_ttl_hashed:10000
|
||||
|
||||
|
||||
cache_size_kb
|
||||
-------------
|
||||
|
|
@ -179,3 +189,19 @@ HTTP but is served to the outside world via a proxy that enables HTTPS.
|
|||
::
|
||||
|
||||
datasette mydatabase.db --config force_https_urls:1
|
||||
|
||||
.. _config_hash_urls:
|
||||
|
||||
hash_urls
|
||||
---------
|
||||
|
||||
When enabled, this setting causes Datasette to append a content hash of the
|
||||
database file to the URL path for every table and query within that database.
|
||||
|
||||
When combined with far-future expire headers this ensures that queries can be
|
||||
cached forever, safe in the knowledge that any modifications to the database
|
||||
itself will result in new, uncachcacheed URL paths.
|
||||
|
||||
::
|
||||
|
||||
datasette mydatabase.db --config hash_urls:1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue