{"html_url": "https://github.com/simonw/datasette/issues/1645#issuecomment-1059633902", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1645", "id": 1059633902, "node_id": "IC_kwDOBm6k_c4_KLru", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-05T01:03:06Z", "updated_at": "2022-03-05T01:03:06Z", "author_association": "OWNER", "body": "I agree: this is bad.\r\n\r\nIdeally, content served from `/static/` would apply best practices for static content serving - which to my mind means the following:\r\n\r\n- Where possible, serve with a far-future cache expiry header and use an asset URL that changes when the file itself changes\r\n- For assets without that, support conditional GET to avoid transferring the whole asset if it hasn't changed\r\n- Some kind of sensible mechanism for setting cache TTLs on assets that don't have a unique-file-per-version - in particular assets that might be served from plugins.\r\n\r\nDatasette half-implemented the first of these: if you view source on https://latest.datasette.io/ you'll see it links to `/-/static/app.css?cead5a` - which in the template looks like this:\r\n\r\nhttps://github.com/simonw/datasette/blob/dd94157f8958bdfe9f45575add934ccf1aba6d63/datasette/templates/base.html#L5\r\n\r\nI had forgotten I had implemented this! Here is how it is calculated:\r\n\r\nhttps://github.com/simonw/datasette/blob/458f03ad3a454d271f47a643f4530bd8b60ddb76/datasette/app.py#L510-L516\r\n\r\nSo `app.css` right now could be safely served with a far-future cache header... only it isn't:\r\n```\r\n~ % curl -i 'https://latest.datasette.io/-/static/app.css?cead5a' \r\nHTTP/2 200 \r\ncontent-type: text/css\r\nx-databases: _memory, _internal, fixtures, extra_database\r\nx-cloud-trace-context: 9ddc825620eb53d30fc127d1c750f342\r\ndate: Sat, 05 Mar 2022 01:01:53 GMT\r\nserver: Google Frontend\r\ncontent-length: 16178\r\n```\r\nThe larger question though is what to do about other assets. I'm particularly interested in plugin assets, since visualization plugins like `datasette-vega` and `datasette-cluster-map` ship with large amounts of JavaScript and I'd really like that to be sensibly cached by default.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1154399841, "label": "Sensible `cache-control` headers for static assets, including those served by plugins"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1645#issuecomment-1059634412", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1645", "id": 1059634412, "node_id": "IC_kwDOBm6k_c4_KLzs", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-05T01:04:53Z", "updated_at": "2022-03-05T01:04:53Z", "author_association": "OWNER", "body": "The existing `app_css_hash` already isn't good enough, because I built that before `table.js` existed, and that file should obviously be smartly cached too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1154399841, "label": "Sensible `cache-control` headers for static assets, including those served by plugins"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1645#issuecomment-1059634688", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1645", "id": 1059634688, "node_id": "IC_kwDOBm6k_c4_KL4A", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-05T01:06:08Z", "updated_at": "2022-03-05T01:06:08Z", "author_association": "OWNER", "body": "It sounds like you can workaround this with Varnish configuration for the moment, but I'm going to bump this up the list of things to fix - it's particularly relevant now as I'd like to get a solution in place before Datasette 1.0, since it's likely to be beneficial to plugins and hence should be part of the stable, documented plugin interface.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1154399841, "label": "Sensible `cache-control` headers for static assets, including those served by plugins"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1645#issuecomment-1061355871", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1645", "id": 1061355871, "node_id": "IC_kwDOBm6k_c4_QwFf", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-08T02:59:28Z", "updated_at": "2022-03-08T02:59:28Z", "author_association": "OWNER", "body": "Hah, found a TODO about this: https://github.com/simonw/datasette/blob/c5791156d92615f25696ba93dae5bb2dcc192c98/datasette/app.py#L997-L999", "reactions": "{\"total_count\": 1, \"+1\": 0, \"-1\": 0, \"laugh\": 1, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1154399841, "label": "Sensible `cache-control` headers for static assets, including those served by plugins"}, "performed_via_github_app": null}