-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add missing max-age cache directive #114
Conversation
and adjust cache time
@ulrikandersen Do you know how this will work? Will the image still be cached beyond one hour in which case the browser shows a stale image while revalidating or does it only apply the SWR logic within that hour? I'm thinking we could cache icons basically infinitely as long as we refresh the image while showing a stale image. |
I am actually not sure how widely supported the |
I think we can quite easily do this, especially if query parameters in a URL are taken into consideration when browsers cache images, but I suppose they are. I'm pretty sure we can get the ID of the commit in which a file was updated through the one request we do to GraphQL. If that's the case then we can just add that as a query parameter to the URL we use for loading the image. That way the URL will change when a new commit is made. |
With the changes in #115 the image URLs will change for every commit to a branch. @ulrikandersen #115 targets this PR so we can test it out if you think this will allow us to cache images more reliably. |
* Fetches images using OIDs * Fetches specifications using OID
With image URLs changing when files change we are safe to instruct browser to cache for a long time (30 days). I have removed |
Adds the max-age directive to the cache control header which is going to tell the browser for how long it should cache the image for.
Max age is set to 1 hour to allow us to change images without waiting for 30 days for users' browser caches to expire.