Avatar of GEMCC
GEMCC
 asked on

Leverage browser caching

Hello,

I am running Google's PageSpeed test and am coming up with:

Leverage browser caching

Everything I am finding is not clear to me.  The site is on an Apache server and I have the expire and header modules running.

Please advise.

Have a great day,

Don
Apache Web ServerPHPSearch Engine Optimization (SEO)

Avatar of undefined
Last Comment
Mohamed Magdy

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mohamed Magdy

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

You may also want to consider adding an expiration on the server so you can send a 304 header for resources that have not changed.  For example, your server does not need to send the same picture over and over again - just tell the browser that the last copy is still OK.
GEMCC

ASKER
Hello,

I got everything installed and working and it sped things up a lot!

One thing I am not sure about, if I understand correctly, step 4 is a config for WordPress.  I am not using WP so where would I place this code/script?

Have a great weekend,

Don
Mohamed Magdy

Step 4 can be made with any type of websites that's why I copied it over to you as it will cache CSS, images, JS, icons and PDF.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
GEMCC

ASKER
Understood, but where do I put the code/script?
Mohamed Magdy

In a file called .htaccess beside your website files in the same folder.
GEMCC

ASKER
Gotcha, there is not an .htaccess file in the same directory as the web files.  Should I just create one and copy your info?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
GEMCC

ASKER
Still waiting on an answer regarding not having an .htaccess file.  Please advise.

In the meantime, I see what you mean, the PageSpeed test fluctuates by 10+ points even if I have not made any changes!

Please let me know about the .htaccess file.

Have a great day,

Don
David Johnson, CD

yes create one and put it in your website root folder
Mohamed Magdy

I'm so sorry I was out of town, yes as David said, create one in your website root folder and put info inside it.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
GEMCC

ASKER
Hello,

I created the .htacces file and added the code you provided, but still the same issue.

Please advise.

Have a great day,

Don
Mohamed Magdy

When you open Leverage browser caching in PageSpeed, what URLs are you seeing? Are they external links? because if their were external links you can't cache them.

The code I provided will cache local files but it won't cache external links.

You can find the result of PageSpeed on my website in an attached image, you can find in it that the un cached links are all external.
2015-05-07-11-30-04.png
Mohamed Magdy

FYI, external links are cached from the external source and it's not possible to cache them until you serve them locally.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
GEMCC

ASKER
Hello,

The ones I am seeing are PNG files are supposedly not being cached, but your code has PNG set.

Please advise.

Have a great weekend,

Don
Mohamed Magdy

Could you please post a screenshot of the links?
GEMCC

ASKER
Well, actually, now it is all cleared up!  I guess it took a while.

Thanks for your help,

Don
Your help has saved me hundreds of hours of internet surfing.
fblack61
GEMCC

ASKER
Resolved issue.
Mohamed Magdy

That's nice to hear, you welcome anytime :)