Skip to content

Commit

Permalink
Use rewrites for placeholders and adjust maximum cache age
Browse files Browse the repository at this point in the history
  • Loading branch information
steverep committed Oct 7, 2023
1 parent ab01e55 commit fb4ae09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,11 @@ For example: <`https://brands.home-assistant.io/_/[domain]/icon.png`>

### Caching

All icons are cached on the client-side browser end for 900 seconds, and cached
by Cloudflare for 604800 seconds.
All icons and logos are cached by browsers for 7 days, so additions and changes may take time to reach all users. This gives users the full benefits of local caching with minimal revalidation, and protects against missing content during an internet outage.

Placeholder images are excepted from this. Placeholder images have a 900 seconds
cache on the client-side and are cached for 1 hour on Cloudflare. This allows
us to replace placeholder images within an acceptable time frame without losing
our cache.
Images are simultaneously cached by Cloudflare for 24 hours. This allows changes to begin being distributed to users relatively quickly without losing the CDN benefits. It also guarantees a simple refresh (F5) will bring content no more than 1 day old.

Image additions and changes may take time to take effect due to caching. The cache is fully flushed in each major version of Home Assistant Core.
The Cloudflare cache is also fully flushed in each major version of Home Assistant Core.

## Image specification

Expand Down
20 changes: 4 additions & 16 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@
command = "bash ./scripts/build.sh"

[[headers]]
for = "/_/_placeholder/*.png"
for = "/*"
[headers.values]
Cache-Control = "public, max-age: 900, s-maxage=3600, must-revalidate"
Access-Control-Allow-Origin = "*"

[[headers]]
for = "/*.png"
[headers.values]
Cache-Control = "public, max-age: 900, s-maxage=604800, must-revalidate"
Access-Control-Allow-Origin = "*"

[[headers]]
for = "/domains.json"
[headers.values]
Cache-Control = "public, max-age: 900, s-maxage=604800, must-revalidate"
Cache-Control = "public, max-age=604800, s-maxage=86400, stale-while-revalidate=604800"
Access-Control-Allow-Origin = "*"

[[redirects]]
Expand All @@ -30,10 +18,10 @@
from = "/_/*/:image"
to = "/_/_placeholder/:image"
force = false
status = 302
status = 200

[[redirects]]
from = "/brands/_/*/:image"
to = "/brands/_/_placeholder/:image"
force = false
status = 302
status = 200

0 comments on commit fb4ae09

Please sign in to comment.