SURFscz / SBS

Samenwerking Beheer Systeem ↣ Collaboration Management System
Apache License 2.0
3 stars 2 forks source link

Use cache headers with long cache duration for images #1387

Closed FlorisFokkinga closed 3 months ago

FlorisFokkinga commented 5 months ago

For instance on https://test.sram.surf.nl/organisations/361/collaborations

image

baszoetekouw commented 5 months ago

This is not really a bug, it's firefox trying to prefetch images, or trying to ascertain that they still exist. Not really a bug.

Having said that, it would probably make sense to improve caching for images. The current cache headers set are:

cache-control: max-age=1209600
cache-control: nocache, private

which probably causes browsers to not cache the images at all. We should probably change this to a long cache duration for all images, as the image url will change if the image is changed anyway.

Better headers for images are probably:

Cache-Control:  public, max-age=31536000, immutable
oharsta commented 5 months ago

@mrvanes The header set in the SRAM application are overridden in Ningx, can you add the headers in SBS Ningx config for all paths api/images/* ?

baszoetekouw commented 1 month ago

Really fixed by https://github.com/SURFscz/SRAM-deploy/commit/850945508e462d08f1caab767cfc30b224d1771a

baszoetekouw commented 1 month ago

works:

╰─▶ curl -v -o/dev/null https://test.sram.surf.nl/api/images/organisations/acbecfd4-040b-40d6-b0d0-2b8f96c589ee 2>&1 | grep cache
< cache-control: max-age=31536000, public, immutable