B rating for static content caching but no cache control headers sent?
|
07-25-2017, 03:22 AM
(This post was last modified: 07-25-2017 12:25 PM by diesel2.)
Post: #1
|
|||
|
|||
B rating for static content caching but no cache control headers sent?
On a Magento site, I get a B rating for caching static content. Mod_expires and Mod_headers are both enabled on the Apache server (2.4.7) running on Ubuntu 14.04. I am only using Magento's default .htaccess which has expires active on and a few directives for specific mime types.
However, the server doesn't seem to send any cache control headers. Here are the headers I see: Quote:root@<username>:~# curl -IL https://www.example.com I am puzzled to know how webpagetest grades my site B for static content caching even though the server is not sending cache control headers of any kind. |
|||
07-25-2017, 09:43 AM
Post: #2
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
Ah... Slight gotcha with Ubuntu...
mod_expires.load being setup - first step. mod_expires.conf - second step. No default mod_expires.conf exists. You must add one to... /etc/apache2/mods-available/mod_expires.conf Then do an a2enmod expires again + this will create the correct mods-enabled links. Then bounce Apache - service apache2 reload - then recheck. Likely this will fix your setup. Like help speeding up your site? Skype me @ ID davidfavor for a quote. Be sure to include your site name in your Skype Add Contact request. |
|||
07-25-2017, 12:23 PM
Post: #3
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
(07-25-2017 09:43 AM)dfavor Wrote: Ah... Slight gotcha with Ubuntu... Thank you, that was it! I did notice the expires.conf was missing, but it didn't occur to me that I could or should add the file and re-enable the mod to get it working. Thanks a ton, again. I spent literally days figuring out why Sucuri was not caching our site and we finally discontinued the service yesterday. This gives me hope that we can get Sucuri to cache our site, after all, because their support said they couldn't cache until our server sent caching headers. One question, though. The default value shows the following: Code: Cache-Control: max-age=1296000 This is about 15 days and is contrary to the mime type specific expires directives I put into expires.conf, which are much longer. Any idea where this max-age is coming from? |
|||
07-25-2017, 02:16 PM
Post: #4
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
Just a quick note... you should never see an expiry header on index.php - unless you're playing around with microcaching.
|
|||
07-25-2017, 02:59 PM
(This post was last modified: 07-25-2017 03:01 PM by diesel2.)
Post: #5
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
@GreenGecko, that went completely over my head, I must confess. Could you please explain a little bit more about what you meant?
The cache control header I quoted appears when I do the following: Code: curl -IL https://www.example.com |
|||
07-26-2017, 08:00 AM
Post: #6
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
(07-25-2017 02:59 PM)diesel2 Wrote: @GreenGecko, that went completely over my head, I must confess. Could you please explain a little bit more about what you meant? The html content of the page is dynamic, so should not be cached ( for example, same page logged in / out, random product selection, timestamp, code update ). It's the static stuff - css, js, woff, etc that can be cached locally. A full page cacher built into the application will take care of this, and reduce the server-side load, but still won't deliver the page with an expiry time in the future. This is the core of why I really don't like services like CloudFlare - they have to proxy to the original server to get a current copy of the html so will always lengthen the TTFB. There is one method - microcaching - that attempts to improve performance by holding a copy of the page for a minute or less, in the hope that it isn't wrong *that* often. |
|||
07-26-2017, 04:08 PM
(This post was last modified: 07-26-2017 04:09 PM by diesel2.)
Post: #7
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
@GreenGecko, thanks for the explanation.
We are indeed using a full page cacher for our Magento site, so the index.php/home page being served is indeed a html file generated from that extension. And, I have the following directive in my expires.conf that relates to html files: Code: ExpiresByType text/html "access plus 15 days" So, is the cache control header alright, in this case? |
|||
07-27-2017, 11:37 AM
(This post was last modified: 07-27-2017 11:37 AM by GreenGecko.)
Post: #8
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
yes that needs to go. will cause plenty of weirdness.
In real terms, assuming you're compressing ( gzip - mod_deflate on Apache ) html, then the overhead of transferring it is rather small - you can optimistically assume a 10x compression of something like 100k of content = 10k ( see why these minifiers are pointless?? ), so as long as the latency is low, delivering a fpc - stored page really won't take a long time at all! |
|||
07-28-2017, 04:52 PM
(This post was last modified: 07-28-2017 04:52 PM by diesel2.)
Post: #9
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
(07-27-2017 11:37 AM)GreenGecko Wrote: In real terms, assuming you're compressing ( gzip - mod_deflate on Apache ) html, then the overhead of transferring it is rather small - you can optimistically assume a 10x compression of something like 100k of content = 10k ( see why these minifiers are pointless?? ), so as long as the latency is low, delivering a fpc - stored page really won't take a long time at all! You are spot on. I went ahead and removed the expiresbytype directive for html. It was quite pointless to leave it enabled. |
|||
10-04-2017, 07:46 AM
Post: #10
|
|||
|
|||
RE: B rating for static content caching but no cache control headers sent?
We had a similar problem.
In our case we had to enable php gzip: zlib.output_compression = On Konstantin Gerasimov Magento Certified Developer https://www.goivvy.com |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)