1

I was running a page speed test and it came up that I'm not leveraging browser caching for images and such. I was hoping to use the header tag to solve this. https://docs.craftcms.com/v3/dev/tags/header.html#app

Where does this go exactly? In the _layout?

2

This is something that is best done via server-side config. The reason is that when an image is requested, for instance, your Twig code that sets the header never gets run for that request.

You can see how it is done via Nginx here: Nginx-Craft

For Apache (don't use .htaccess pls) go here: html5 boilerplate apache

  • I have arcustech hosting and I reached out to them to set them up via config but they just told me to do it via .htaccess Why do you say not to do it that way? – Danielle Frappier Sep 18 '18 at 20:01
  • I'm probably being pedantic about it, but my reasoning is here: Stop using .htaccess files! No, really. -- but you are using managed hosting where you don't have access to the server config, so you probably have no choice. – andrew.welch Sep 18 '18 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.