PostHog / posthog

🦔 PostHog provides open-source web & product analytics, session recording, feature flagging and A/B testing that you can self-host. Get started - free.
https://posthog.com
Other
21.85k stars 1.3k forks source link

Static asset caching means some assets only change once a day #17205

Open pauldambra opened 1 year ago

pauldambra commented 1 year ago

We serve some assets from cloudfront. This is bueno because they have deployment specific names like 1c-2MRDOHUS.js

We have some assets with fixed names.

Maybe only toolbar.js and toolbar.css.

This means if we deploy a fix to the toolbar (and don't realise this) people only get the fix 24 hours later. And, if we deploy a change and then test it in production we're not really testing the new code.

The cache policy is

data "aws_cloudfront_cache_policy" "this" {
  name = "Managed-CachingOptimized"
}

If we extend this to allow it to be varied by a t=blah header then posthog-js could add this header so that we can control the cache length. E.g. you could set a t=blah so that any five minute window from any client would get the same value so that we have a five minute cache.

pauldambra commented 1 year ago

this is true for toolbar.js as well but on a different cloudfront distribution