transport-nantes / tn_web

site web des Mobilitains
https://www.mobilitains.fr/
GNU General Public License v3.0
16 stars 8 forks source link

mobilito plots don't cache #1016

Open JeffAbrahamson opened 1 year ago

JeffAbrahamson commented 1 year ago

The images set a cookie, which they don't need to do, but which leads to them not being served from cloudflare

Shriukan33 commented 1 year ago

Maybe we should add a timeseries_plot imagefield to mobilito_session model and save it there ? Instead of rendering it everytime

JeffAbrahamson commented 1 year ago

Maybe we should add a timeseries_plot imagefield to mobilito_session model and save it there ? Instead of rendering it everytime

Even better is to serve it once and not again. We want it cached on the edge, not cached on our server.

Shriukan33 commented 1 year ago

And why isn't it cached already then ? The image name seems to be constant, why isn't cloudflare picking it ?

JeffAbrahamson commented 1 year ago

The images set a cookie, which they don't need to do, but which leads to them not being served from cloudflare

Shriukan33 commented 1 year ago

A cookie ? image

I'm afraid I'm a bit lost here, I don't see cookies, and even then, how would that prevent cloudflare from picking the file ?

JeffAbrahamson commented 1 year ago

Pretty sure sessionid comes from django, and that we can selectively turn it off, if only by deleting it from the response we serve. Need to check the docs on cache control and search for "django cloudflare" to see what's known.

jeff@birdsong:~ $ curl -I https://beta.mobilitains.fr/mobilito/session_ts_img/701dda65c29562ba376dcba4ad196613941a8970/
HTTP/2 200 
date: Thu, 01 Dec 2022 16:39:09 GMT
content-type: image/png
content-length: 38905
x-frame-options: DENY
vary: Cookie
x-content-type-options: nosniff
referrer-policy: same-origin
cross-origin-opener-policy: same-origin
set-cookie: sessionid=yuc04bni6v91swbomixo2h1ujg71eys2; expires=Tue, 30 May 2023 16:39:09 GMT; HttpOnly; Max-Age=15552000; Path=/; SameSite=Lax
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=R7n3yBAiE6%2BWIfar0gl7yoAYuBLmag2oZHa%2FTtcM3MoW5VWMqML3dJBCXszQJpHR%2Fe%2BnmB2DdDbu0SmyDUhiN%2F%2BzFVy2hIgp1dtU%2B5uD1l7ET%2F8xlcKZyKU2rPZLQDV3JuymMKnX"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 772d41da3da7f108-CDG
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

jeff@birdsong:~ $
Shriukan33 commented 1 year ago

The header says "server: cloudflare" in your CURL and also in my browser :

image

Isn't it what you were looking for ? What makes you think it's in fact not Cloudflare ?

Shriukan33 commented 1 year ago

@JeffAbrahamson bump