How do I set an expiry date or a maximum age in the HTTP headers?

Hello- Anyone have any insights into how to set a date and/or maximum age that goole likes? My whole site is getting this error. Is this done at the server level?

Thanks!

Hi, can you please be more specific? What error are you referring to? This is usually done via a .htaccess file within your account. If you have invalid code it can cause a server error and break your site.

Greg

Hey Greg- Man, I’m sorry… I don’t know why I wrote error… its not an error at all (trying to do too many things at once). Its a strong suggestion from google pagespeed.

Right now, the site is getting a 50/100. The exact message page speed is giving me is:

Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
Leverage browser caching for the following cacheable resources:

Then a bunch of links are listed. Its my limited knowledge that tells me this should be done at the htaccess level, but I wouldn’t know the code snippet to put in there.

Its also telling me:

Eliminate render-blocking JavaScript and CSS in above-the-fold content

But I think this is done at the theme level.

Thx!

This is interesting. I went ahead and added what looks like standard script to my htaccess file.

Not really any difference.

BUT… When I turned off Cloudflare (development mode), mobile went from 50/100 to 60/100 and desktop went from 70/100 to 86/100. It also just felt faster at the browser level.

Anyone have any thoughts on this?

Thx!

@wphall

Hey Bill…

This leverage browser caching one usually is occurring because you forgot the expire meta data tag as per example…

<meta http-equiv="Expires" content="30" />

where 30 is the number of days for the browser cache to check for updates to the page (don’t on a site wide level or per page level… use per page is useful if you have a page that is updated frequently, like daily, then you would add the meta tag and change it’s value to 1 for recheck daily)

This one is referring to javascript being in the head instead of referenced near the bottom of the closing head tag I do believe. Unfortunately there is little that can be done about this at present as it is in the control of RW and Stacks, but I do believe they are working on a fix in V7 for it.

You shouldn’t have had to change anything in your .htaccess file… dangerous ground to be in there lol

Have no idea on the Cloudflare issue as I don’t use it. But basically as I understand it, Cloudflare is a SSL cheat and a caching service for your website. so perhaps you didn’t have the DNS settings correct in Cloudflare or your Domain name??? just guessing on this one…

Brad

1 Like

Hey @Turtle I saw your post about header expiry dates and also have the same situation and want to know how do I add the code you suggested - to my project file. I am on Foundation and am using SEO HELPER. Where and how would I add this code?
Thank in advance, Anu

adding to my ./public_html/.htaccess file improved the site speed very much.