chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v3.0
144 stars 36 forks source link

Use stale-if-errror in Cache Control when available [🟥 awaiting full support] #2291

Open chrisblakley opened 3 months ago

chrisblakley commented 3 months ago

https://caniuse.com/mdn-http_headers_cache-control_stale-if-error

Screenshot 2024-08-21 at 11 06 22 AM

When this is supported, I'm thinking we only incorporate it into static files like images and fonts. Maybe CSS too.

<FilesMatch "\.(ico|pdf|flv|png|gif|jpg|jpeg|svg|woff|woff2|mp3|css)$">
    Header set Cache-Control "max-age=31536000, stale-while-revalidate=2592000, stale-if-error=86400, public"
</FilesMatch>

The above would have a max age of 1 year, then for the next 30 days it would return the "stale" resource but revalidate in the background. On error, it would return the stale resource for 1 day. I'd like to consider extending that 1-day length to be longer as well... Maybe use 2592000 there too?

Would this be beneficial for PHP/HTML requests? I need to research what is considered an "error" state where the stale resource would be used...

Related: #1844