lfortran / lcompilers_frontend

The sources of the web LFortran GUI interface

Home Page:https://dev.lfortran.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updated gist sometimes loads the old one

certik opened this issue · comments

When I updated a gist, it still loads the old gist. Here is an example: https://lfortran.github.io/pull_request_preview/lfortran/96?gist=certik/b6d162bee7fdd7711722221a90729a2a, in a private window it loads the new gist, but in the old window it loads the old gist.

This one is very hard to reproduce, as it seems there is some caching going on, and even Command+Shift+R does not reload it correctly. But eventually it resolves itself.

However it's confusing if people want to update the gists as they work on the code and want to reuse the hash.

When I updated a gist, it still loads the old gist.

There seem to be two issues here:

  1. After updating a gist, the raw link gist.githubusercontent.com to that gist does not reflect the changes for sometime. It seems to get updated after some time. This might be some feature/limitation of GitHub or githubusercontent.com that it updates after sometime. This is probably not in our capacity to fix.
  2. The fetch request seems to cache values at the client side. I think there are approaches to fix this. For example using { cache: 'no-store' } or { cache: 'no-cache' } in fetch() (reference https://stackoverflow.com/a/42518434). Or using an external library for fetch().

We can probably fix2., but I think 1. is still a blockage. To fix 1. we might need to switch to a different url or approach to fetch the required data/source-code. For example, using api.github.com (It seems one can use this without any token with a rate limit of 60 requests per hour and 5000 requests per hour if someone provides a authorization token to it.)

Let's fix 2., and then we document 1. As long as users understand what is going on, it's fine. Users will understand that there is nothing we can do, if github shows the old version.

@Shaikh-Ubaid how long does it typically take for github to update the url, as tested with, say, curl or wget?

how long does it typically take for github to update the url

It seems to get updated in like 5 mins. Also, it seems many people experienced this caching issue https://github.com/orgs/community/discussions/46691, https://github.com/orgs/community/discussions/46758. (I went through some parts of the discussion. People suggested different ways like using a random dummy parameter in the url to force the request to load a new copy of the file. I tried it. It does not seem to work perfectly yet.)

PS: I think the cache timing is set to 5 mins max (https://github.com/orgs/community/discussions/46691#discussioncomment-4948987 (first comment and last comment in this) or https://github.com/orgs/community/discussions/46691#discussioncomment-4987251 (last line)).

as tested with, say, curl or wget?

PS: I tested with just the browser tab. Other people reported similar values, so I guess it is probably correct.

5 minutes is fine. We document it, and as long as it is reasonably reliable, and as long as we disable the react caching, it should be ok.

We document it

Please, could you share where we should document it? It seems we do not yet have documentation related to the features at dev.lfortran.org.

For now in the README. Let's document the features (that you can use "gist") and that it takes about 5 minutes to update by GitHub for every change.

We can later add documentation at dev.lfortran.org as well.