greasyfork-org / greasyfork

An online repository of user scripts.
https://greasyfork.org
GNU General Public License v3.0
1.46k stars 435 forks source link

[Bug] The latest version is not available as the old version is cached #1220

Closed cyfung1031 closed 9 months ago

cyfung1031 commented 9 months ago

@JasonBarnabe The file cache issue is still here.

After the script is JUST updated via webhook.

This is verified by the fetch API, with option cache: 'reload'

In the DevTools, the request is sent with Cache-Control: no-cache

The version on the Greasy Fork webpage is shown correctly with is 3.2.35 after it is just updated using webhook.

However, the responded file is still the old version. // @version 3.2.34

The Last-Modified also refers to the old version rather the update just now. 05 Dec 2023

Screen Shot 2023-12-10 at 21 51 47 Screen Shot 2023-12-10 at 21 52 05

After few minutes of the update

Example Screenshot for Status Code 200 OK (from disk cache)

Screen Shot 2023-12-10 at 22 23 24

After few hours

Related Issue

JasonBarnabe commented 9 months ago

After an update, there is a cron job that runs every minute to ensure the cached latest code is cleared on every server. If you request the code within a minute of an update, there's a good chance you will still receive an older version.

Specifically looking at the cache status of the file in your first set of screenshots, I can see that (in UTC times):

Generally, I don't think this is a problem for normal use. It's not a big deal that there is a potential one minute delay for updates, as you're dealing with hours-long delay for updates anyway due to the frequency of update checks.

If you're doing something programmatic and want to bypass the browser cache, I suggest just adding a timestamp to the URL.

JasonBarnabe commented 9 months ago

Closing per above.

cyfung1031 commented 9 months ago

After an update, there is a cron job that runs every minute to ensure the cached latest code is cleared on every server.

I don't understand why you need to do it with an one-minute interval.

There are only two ways to update the script

  1. from the greasy fork web
  2. from the webhook / regular checking in a fixed interval (auto update)

Both will trigger the adding of @updateURL and @downloadURL

You just need to clear the cache after the addition of @updateURL and @downloadURL There is no need to clear the cache for every one minute.

If you're doing something programmatic and want to bypass the browser cache, I suggest just adding a timestamp to the URL.

I tried. In the old days, I can always get the latest code using https://greasyfork.org/scripts/1-testing/code/XXXXXXX.user.js by replacing the XXXXXXX to a random string.

Now, I cannot find anyway, including adding a timestamp to the URL, to get the latest code after it is just updated.

Now the old url just redirect to the cached url.