Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashed URLs should be optional #418

Closed
simonw opened this issue Mar 15, 2019 · 5 comments

Comments

Projects
None yet
1 participant
@simonw
Copy link
Owner

commented Mar 15, 2019

The cute performance hack where a hash of the DB contents is included in the URL makes a lot less sense when serving files that frequently change. It's also difficult to explain to people.

It should be optional and default to "off".

Needed for #417 and #419

@simonw

This comment has been minimized.

Copy link
Owner Author

commented Mar 17, 2019

In #419 I'm now proposing that Datasette default to opening files in "mutable" mode, in which case it would not make sense to support hash URLs for those files at all. So actually this feature will only be available for files that are explicitly opened in immutable mode.

@simonw simonw closed this in 6f6d0ff Mar 17, 2019

@simonw

This comment has been minimized.

Copy link
Owner Author

commented Mar 17, 2019

The design of this feature is discussed extensively in the comments on pull request #416

Some demos:

~ $ curl -i 'https://latest.datasette.io/fixtures-dd88475/facetable' 
HTTP/2 200 
date: Sun, 17 Mar 2019 23:05:21 GMT
content-type: text/html; charset=utf-8
content-length: 17555
cache-control: max-age=31536000

</html>~ $ curl -i 'https://latest.datasette.io/fixtures/facetable' 
HTTP/2 200 
date: Sun, 17 Mar 2019 23:05:40 GMT
content-type: text/html; charset=utf-8
content-length: 17410
cache-control: max-age=5

There are now three config settings relevant to the above:

default_cache_ttl - defaults to 5s. The default cache TTL for non-hashed resources.
default_cache_ttl_hashed - defaults to 31536000s. The default cache TTL for hashed resources.
hash_urls - defaults to False. If True, all URLs will attempt to redirect to their hashed version.

@simonw

This comment has been minimized.

Copy link
Owner Author

commented May 11, 2019

Actually right now https://latest.datasette.io/fixtures/facetable?_hash=1 redirects to https://latest.datasette.io/fixtures-000/facetable - because we are no longer calculating hashes on startup for non-immutable databases. So that's weird.

@simonw

This comment has been minimized.

Copy link
Owner Author

commented May 11, 2019

I'm going to re-open this, because some of this needs revisiting now that we aren't running .inspect() and hence are not calculating hashes for anything other than immutable databases (and databases are treated as mutable by default).

@simonw simonw reopened this May 11, 2019

@simonw simonw added this to the 0.28 milestone May 11, 2019

@simonw simonw added the large label May 16, 2019

@simonw

This comment has been minimized.

Copy link
Owner Author

commented May 16, 2019

I'm ready to close this now thanks to fixing #471

@simonw simonw closed this May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.