Skip to content
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

Creation time of images #3

Open
jmozmoz opened this issue Jan 7, 2024 · 3 comments
Open

Creation time of images #3

jmozmoz opened this issue Jan 7, 2024 · 3 comments

Comments

@jmozmoz
Copy link

jmozmoz commented Jan 7, 2024

Is there a way to access the creation time of the images? By this one could wait 3 hours before downloading a new file.

Currently the images do not contain EXIF data and the server response with this header:

t = 'https://clouds.matteason.co.uk/images/2048x1024/clouds.jpg'
response = requests.head(t, allow_redirects=True)
print(json.dumps(dict(response.headers), indent=4))
{
    "Date": "Sun, 07 Jan 2024 15:03:36 GMT",
    "Content-Type": "image/jpeg",
    "Content-Length": "453521",
    "Connection": "keep-alive",
    "last-modified": "Sun, 07 Jan 2024 14:40:10 GMT",
    "access-control-allow-origin": "*",
    "etag": "\"659ab7ca-6eb91\"",
    "expires": "Sun, 07 Jan 2024 14:56:22 GMT",
    "Cache-Control": "max-age=600",
    "x-proxy-cache": "MISS",
    "x-github-request-id": "D7A6:3CB921:4663A39:478CE79:659AB93E",
    "via": "1.1 varnish",
    "x-served-by": "cache-fra-eddf8230113-FRA",
    "x-cache": "MISS",
    "x-cache-hits": "0",
    "x-timer": "S1704638782.245013,VS0,VE116",
    "vary": "Accept-Encoding",
    "x-fastly-request-id": "d37c7c93eee1d54d41bbf3af796af759af214a7b",
    "CF-Cache-Status": "REVALIDATED",
    "Accept-Ranges": "bytes",
    "Report-To": "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=HcZUwe2O41bkdngpsz%2FeRquqDosFjSkMRrYWri%2FNvekWfdQ91DnaRhMtXxdsYvD7ussoKqgzLnrtu6yxtNp4Uii2pJvcg2uhh%2F%2BfiVW%2FXcUl8waPfh%2Bxc4MDJ5zSgU6C1N%2FfYWvlE3CW\"}],\"group\":\"cf-nel\",\"max_age\":604800}",
    "NEL": "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}",
    "Server": "cloudflare",
    "CF-RAY": "841d16a639d16d6e-MUC",
    "alt-svc": "h3=\":443\"; ma=86400"
}

Date is the time of downloading and last-modified seems to change every 30 minutes. It would be best, if this information were available in the header sent by the server. Of perhaps in a separate text/json file on the server.

@jmozmoz
Copy link
Author

jmozmoz commented Jan 7, 2024

Okay, I guess the 30 minutes interval of new images results from this: https://github.com/matteason/live-cloud-maps/blob/main/.github/workflows/generate-images.yml#L6

So in fact it is a new image every 30 minutes. So I guess it would require more work to determine if the base images have changed and store this information somewhere.

@matteason
Copy link
Owner

Hi @jmozmoz - yes, this is a good idea. Ostensibly the source data is updated every three hours, but the workflow runs more frequently because sometimes the base images contain holes which later get filled in.

What I could do is take a hash of the newly generated file, compare it to the currently published file, and only republish if it's changed. Then the last-modified should be accurate and you could issue a HEAD request to determine if you need to refetch.

@jmozmoz
Copy link
Author

jmozmoz commented Jan 9, 2024

See jmozmoz/cloudmap#12 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants