You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While setting the correct Nginx config will reduce usefulness we can improve speed by setting a cache control header if our page is served from cache, or can be/will be/has been cached
While setting the correct Nginx config will reduce usefulness we can improve speed by setting a cache control header if our page is served from cache, or can be/will be/has been cached
By default Laravel will not set cache control, causing Symfony to always return
cache-control: no-cache, private
https://github.com/symfony/symfony/blob/6f4f04b98f6134996a57d21d1851d558a34dc45c/src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php#L251
Which honestly is a safe default since Laravel cannot know what can and can't be cached. That is dependent on the page.
However, if Statamic can cache the page statically we can assume a browser and CDN could cache the page too.
https://github.com/statamic/cms/blob/779a92a223d16ee16f6af6de0b6a9acfc95be082/src/StaticCaching/Middleware/Cache.php#L111
https://github.com/statamic/cms/blob/779a92a223d16ee16f6af6de0b6a9acfc95be082/src/StaticCaching/Middleware/Cache.php#L84
These places would need to be updated with
->setPublic();
https://github.com/symfony/symfony/blob/6f4f04b98f6134996a57d21d1851d558a34dc45c/src/Symfony/Component/HttpFoundation/Response.php#L604->setMaxAge();
https://github.com/symfony/symfony/blob/6f4f04b98f6134996a57d21d1851d558a34dc45c/src/Symfony/Component/HttpFoundation/Response.php#L788
->setStaleWhileRevalidate();
https://github.com/symfony/symfony/blob/6f4f04b98f6134996a57d21d1851d558a34dc45c/src/Symfony/Component/HttpFoundation/Response.php#L820
if possible it would be a really nice added bonus to set the Etag
https://github.com/symfony/symfony/blob/6f4f04b98f6134996a57d21d1851d558a34dc45c/src/Symfony/Component/HttpFoundation/Response.php#L949
Here's how laravel implements it if you use their cache control middleware
https://github.com/laravel/framework/blob/43993ed92af54aa8620d8e779a7dcd658f44364c/src/Illuminate/Http/Middleware/SetCacheHeaders.php#L66
aka
->setEtag(md5($response->getContent()))
This will allow the browser and CDN to skip downloading the body if it's still in cache and matches the etag.
having set up my Nginx settings as in statamic/docs#1602 and configuring Cloudlfare to generate/pass Etags my "Content download" of a cached page is 2ms
The text was updated successfully, but these errors were encountered: