Basic Settings - Mod_pagespeed with W3 Cache Plugin for Wordpress

3,221 views
Skip to first unread message

Alice feels Happy

unread,
Aug 20, 2011, 11:02:01 PM8/20/11
to mod-pagespeed-discuss
Hi, Wondering if anyone is using

Mod_pagespeed
together with
W3 Cache Plugin for Wordpress

I have just moved to a Linode from shared hosting and am now able to
use Mod_pagespeed.

Previously I've been using the W3 Cache Plugin. I have basically all
the W3 cache options turned on except excluding 1 js file that does
not seem to like being combined/minified, and I don't have a CDN so I
don't use that option.

I know I need to turn off some of the W3 Caching options but I'm
wondering if anyone who is familiar with both Mod_pagespeed and the
the W3 Cache plugin could give me configuration advice?

My site isn't a high traffic site but I really want to make it as
zippy as possible for a good user experience.

A Boston

unread,
Aug 22, 2011, 9:38:05 PM8/22/11
to mod-pagesp...@googlegroups.com
pages should be darn fast.

im more familiar with the WP plugins since mod_pagespeed is somewhat
new and beta. but can hazard a decent guess.

mod_pagespeed should not effect the w3 cache plugin in any way since
w3 is a pure WP framework plugin. it places no directives into
.htaccess or apache config files. the combination is perfect, imho.

several others will conflict. for example, w3 super plugin and w3
total cache add .htaccess directives. super cache actually used w3
cache for the object caching. these two and others will conflict (the
better word is confuse or confound) your use of mod_pagespeed. you
will find it difficult to narrow down which .htaccess directives are
working the best. moreover, removing super cache or total cache will
remove directives from .htaccess and then you're somewhat lost. save
the .htaccess files on an ongoing bais.

you need to really focus on tuning your directives. this site is the
best ive seen for tuning. http://webpagetest.org

my advice would be to install mod_pagespeed with wp cache, assuming
you have root access to your web server. if not then you should use WP
super cache or total cache plugins. and im building an image
optimizing plugin (resizing to the width and height). it will be done
soon. but php is a horrid language.

Vid Luther

unread,
Aug 22, 2011, 10:42:04 PM8/22/11
to mod-pagesp...@googlegroups.com
While the answer here may be factually correct, I think I should add my two cents in, regarding real world usage and performance gains.

Your best bet here is to use bat cache, as it's going to build a static page and store it in memcached for you for as long as you need it. 

Use mod_pagespeed to optimize/minimize the end html. You can even speed up things more, using Mark Jaquith's APC object-cache plugin. 

If you're going to use mod_pagespeed, you don't really need a complex plugin like w3 total cache or wp super cache`, it's just going to call a bunch of files and check to see if you have certain settings on, and most of them can be off.

Use mod page speed for.. 

- html minification
- js minify and combine
- replace certain urls to point to your cdn

All you really need from WP then is bat cache, and the APC object cache by Mark. If it's an image heavy site, use the WP Smush.it plugin and bulk smush most of the images before hand. Start with the 3 basic things for Pagespeed, and then add more things as you see your site/theme not break. 

In our tests, when possible, using bat cache is much better than the other heavier plugins. You can see bat cache at work by viewing the source of sites hosted on WordPress VIP and search for 'batcache' . Techcrunch.com is a fairly big example. 

If your site is low traffic, I would change some of the variables in the plugin to actually cache for longer than 300 seconds, as content probably won't change as fast. 




Vid Luther
CEO/Founder
ZippyKid

Alice feels Happy

unread,
Aug 24, 2011, 7:36:28 AM8/24/11
to mod-pagespeed-discuss
Thanks. Vic, I'm going to try that combo will report back.

Switching off W3 Cache and switching on mod page speed with all the
core modules doesn't seem to have broken anything. I also added the
inline js module.

My page speed score is 97 which I think is quite cool.

I've also installed the APC object-cache plugin and will take on
batcache once I see how the object cache plugin is going.

Vic - just out of interest, did I turn up on your alerts because I
mentioned "zippy" in my post? I had a good look at your company site
and it looks cool. I am enjoying DIY for the learning experience but
it sounds like you are doing cool stuff.
> > best ive seen for tuning.http://webpagetest.org
>
> > my advice would be to install mod_pagespeed with wp cache, assuming
> > you have root access to your web server. if not then you should use WP
> > super cache or total cache plugins. and im building an image
> > optimizing plugin (resizing to the width and height). it will be done
> > soon. but php is a horrid language.
>

Vid Luther

unread,
Aug 24, 2011, 7:50:23 AM8/24/11
to mod-pagesp...@googlegroups.com
Alice, no I've been lurking on this list since it started.. And we've
been testing mod page speed since for our customers.. You asked a
question I knew I could answer intelligently...so :)

But good idea on the alerts thing... I should try it :)

Sent from my iPhone

On Aug 24, 2011, at 6:46 AM, Alice feels Happy

Alice feels Happy

unread,
Sep 5, 2011, 9:24:01 PM9/5/11
to mod-pagespeed-discuss
Just to update:

I have mod page speed working with batcache and the APC object-cache
plugin for my Wordpress site. It has been running with this setup for
a few weeks and I'm not having any problems. I have all the default
page speed modules enabled.

My average pageload speeds are still around 2.4 secs (faster than 61%
of sites) according to webmaster tools, so I'd like to get this down a
bit more. I don't have a CDN and I could do a bit more with sprites,
but other than this, all the basics are taken care of e.g. smushed
images, minimal plugins.

I'm interested in exploring fragment caching and trying out Nginx at
some point.

Also - Sorry Vid for spelling your name wrong!

Adrian Boston

unread,
Sep 6, 2011, 3:13:47 PM9/6/11
to mod-pagesp...@googlegroups.com

that is good but not great.

send a tested url from http://www.webpagetest.org/
and it would be possible to offer more information.

i have reached < 2 without a cdn. cdn is helpful for east/west coast and intl visitors but has little benefit for local. depends on your customer base. pick your server wisely.
who is your provider.

Adrian Boston
adrian...@gmail.com
http://adrianboston.com

Vid Luther

unread,
Sep 6, 2011, 12:43:19 AM9/6/11
to mod-pagesp...@googlegroups.com
Alice, no problem on the name :). 

1. Have you run your site through web page test.org? that'll give you a better idea of what else you need to tweak..  the web master tools page load thing is useful on sites with a lot of visitors, for fewer visitors there's also a level of accuracy that google gives you..so you have to keep that in mind.

CDN's are easy, I can provide you with a zone on our CDN if you like, for testing purposes (we use NetDNA).. 

For fragment caching etc, there aren't really any plugins in WordPress that'll help you... it's fairly new to the WP community, you can research transient caches though.. google for that, and look for talks by Andrew Nacin.. 

I've also found Varnish to be an awesome http accelerator in front of apache, for sites that don't change their content much, you can get some crazy speeds with varnish talking to an apache back end. 


--
Vid Luther
CEO and Founder
ZippyKid
Managed Wordpress Hosting
http://zippykid.com/
210-789-0369

Alice feels Happy

unread,
Sep 7, 2011, 10:38:54 PM9/7/11
to mod-pagespeed-discuss
Vid - Do you have an example of a VCL config file that plays well with
wordpress and mod page speed? If yes, would you mind doing a pastebin
so I can see it?

I'm trying Varnish in front of apache as you suggested. Did you need
to make any changes to the mod page speed config to get varnish and
mod page speed working together? I'm trying to figure out if I need to
do anything with ModPagespeedMapOriginDomain or
ModPagespeedMapRewriteDomain or whether that's not relevant at all.

I have used webpagetest quite a bit. I'm mostly getting first page
loads at 2 -2.5 secs and repeat views in the 1.5 - 1.8 sec range.

Alice feels Happy

unread,
Sep 8, 2011, 11:50:44 AM9/8/11
to mod-pagespeed-discuss
I have a feeling I'm doing something basic wrong or thinking about
something the wrong way but I'm stumped...

With Varnish in front of apache, the inline javascript and inline
small images filters aren't working anymore. I'm still getting
optimized images and I can see my URLs are being trimmed in my page
source, so mod page speed is doing something, but not everything.

I tried specifying the server file paths in pagespeed config for the
image and js files in case that helped but it didn't.

I tried turning batcache off and that didn't seem to make a
difference.

Any ideas team?

On Sep 8, 2:38 pm, Alice feels Happy <alice.feels.ha...@gmail.com>

Joshua Marantz

unread,
Sep 8, 2011, 12:25:29 PM9/8/11
to mod-pagesp...@googlegroups.com
Here's one thought.

You might be aware of this already, but mod_pagespeed will typically not optimize resources on an HTML page the first time the page is visited.  That first visit will cause mod_pagespeed to fetch the origin resources.  If you wait a few seconds and press Shift-Refresh again in your browser you should see optimized resources.

If not, there may be a clue left behind in the error.log if you restart apache with "loglevel debug".  I would just leave it in 'debug' mode while analyzing this problem, because otherwise mod_pagespeed will fill up your disk with details of what it's doing.

Nothing in your email indicates to me why you might be getting an optimized resource (e.g. cache-extended or image-compressed) but not inlined.

Hope this helps,
-Josh

Vid Luther

unread,
Sep 8, 2011, 12:43:27 PM9/8/11
to mod-pagesp...@googlegroups.com
Sorry for taking so long to respond, business came up..

the VCL we're using is slightly modified from the one on varnish-cache.org

The only think it'll be doing is caching whatever apache sends it, so there shouldn't be anything special you need to do.

If you run varnishstat you'll be able to tell if things are being cached or not.. what may have happened as Joshua pointed out, is
that varnish cached the page on the first load.. and since nothing changed, it's still serving that html ..

If you're using Varnish 2.0 you can use the php-varnish plugin for WordPress, if you're using 3.0 you can use our fork

https://github.com/zippykid/php-varnish

and then actually purge the varnish cache from within WordPress itself, as long as the ACL's allow it :).


Vid Luther
CEO/Founder
ZippyKid
210-789-0369

Joshua Marantz

unread,
Sep 8, 2011, 12:51:32 PM9/8/11
to mod-pagesp...@googlegroups.com
Vid may be right -- I didn't think about Varnish caching the non-yet-completely-optimized HTML coming out of mod_pagespeed.  However I think it would be a bug for Varnish to do that because mod_pagespeed currently sets cache-control headers that should prevent caching of HTML coming out of Apache.  We are working on improvements to mod_pagespeed to allow caching of HTML but this feature is not released yet.  When we do release it, the max-age will always be a small number of minutes (1 or 2 I think) and we will not set the caching header on a partially optimized page.

Does your VCL cause HTML caching headers to be ignored?

But I think it *does* make sense to cache HTML upstream of mod_pagespeed e.g. with a Wordpress plugin.

-Josh

A Boston

unread,
Sep 8, 2011, 1:00:57 PM9/8/11
to mod-pagesp...@googlegroups.com
cut and paste the url from webpagetest.org
will show some of the issues. otherwise its hard to say

A Boston

unread,
Sep 8, 2011, 2:10:40 PM9/8/11
to mod-pagesp...@googlegroups.com
one thought for alice.

you mentioned your site is not a busy one.

any added cache plugin will always add code and thus always add time
for the first visitor within a determined time period.

a cache advantage comes into play with multiple users. in a real
sense, the first user has a bad experience but the followers do not.

for example, in w3-total-cache the default cache timeout is 180
seconds. or 3 minutes.

here are my results with object cache turned on and using mod_pagespeed:
within the window: 1.656 s
outside the window: 2.456 s

the object cache works awesome within its period, but doesn't outside
that period.

here is my time with no cache at all, only using mod_pagespeed.
1.973 s

that simple solution is pretty good.

unless you have a visitor within that 3 minute window, the cache is an
added burden not an advantage.

most of the real world cases it is cached for ... no one. and many of
your infrequent users will experience the slower performance.

so for a site with infrequent visitors, set your timeouts for a very
long period -- or don't use those caches.

you can 'prime the pump' or preload the cache. w3-total-cache doesn't
have that option. i have seen it on others. its a good solution, but
you still have to determine a suitable timeout period.

an integral part of the performance is monitoring your traffic and
setting appropriate times.

mandatory settings for a site with infrequent visitors are those that
decrease the used bandwidth and trips to the server. such as gzip
text, minify js, clipping images to width/height, and browser caching
for identified content. in my opinion, that is exactly what
mod_pagespeed offers. an advantage for all users.

it probably should remain that way, without caches since most sites in
the web are infrequently visited. or permit changes over time period.

A Boston

unread,
Sep 8, 2011, 3:43:58 PM9/8/11
to mod-pagesp...@googlegroups.com
w3-total-cache does have a 'prime' function under the page setting. my bad.

"Automatically prime the page cache"

which uses the sitemap.xml files. a very good solution.

however, the garbage collection setting of 3600 seconds is fixed. one
hour is good for a light site. those numbers should match -- as long
as the prime runs after the garbage.

Vid Luther

unread,
Sep 8, 2011, 4:09:49 PM9/8/11
to mod-pagesp...@googlegroups.com
I couldn't agree more with the basic message Adrian is trying to convey here. 

You have to know a lot of things before you decide on a caching mechanism, there is no silver bullet. 

I see a lot of posts talking about the mysql query cache, and i see a lot of times when the mysql query cache is the culprit for slow sites.. same for object cache, w3, wp-super.. etc



Vid Luther
CEO/Founder
ZippyKid

Alice feels Happy

unread,
Sep 11, 2011, 10:28:47 AM9/11/11
to mod-pagespeed-discuss
Hi - thanks folks. yup that seems to be what's happening.

With batcache turned on, I can see that I am getting varnish cached
pages because the page source says batcached for 3600 seconds and that
number stays the same after reloading the page, rather than decreasing
as it would if I was getting a new page on reload.

Josh when you ask "Does your VCL cause HTML caching headers to be
ignored?" do you mean that mod page speed should be telling varnish
not to cache any html?

I'm a complete newb (having only just moved from shared hosting to a
VPS) so I'm not sure if I'm getting this right but the varnish docs
(https://www.varnish-cache.org/docs/trunk/tutorial/
increasing_your_hitrate.html) say

[The Cache-Control instructs caches how to handle the content. Varnish
cares about the max-age parameter and uses it to calculate the TTL for
an object.

“Cache-Control: nocache” is ignored but if you need this you can
easily add support for it.]

I'm trying to understand if its this default that causes the html
caching headers to be ignored or if it is something in my VCL config?
This is my VCL config http://pastebin.com/vSZEvywM

The setup with varnish is the best speeds I've gotten so I'm keen to
keep it, but does that mean I basically won't be able to use mod page
speed? Or, might there be some way of controlling the settings so that
varnish doesn't cache the page until mod page speed has had a chance
to do it's optimizing?

Over the weekend I've done a bit of work combining some js files etc
on my own, so I'm gradually reducing my need to use mod page speed,
but I do really like it. For example, I don't know how it does such an
awesome job at reducing the size of my jpg files. I have actually
just saved the mod page speed versions of my jpgs as my new originals
because the file sizes were much smaller than achieved with smush it.
(yes they're still actual jpgs and not the new alternative format).

Here's my test results
- detailed view for run 1 http://www.webpagetest.org/result/110911_6F_4ce2cf42bb2a5a85dcc1ae3ee6ade2f0/1/details/
- full results http://www.webpagetest.org/result/110911_JA_bc345bf8f41304674aaa38f8baf3402e/

I'm still working on... I can't get Tim's varnish purging WP plugin to
work - have contacted him and he has said he is aware of some issues.
I'm getting "Error: Authentication required; see
VarnishAdminSocket::set_auth" when I try to purge. I thought I might
have the purge auths wrong in my config. Now that I can see Varnish is
giving me some very nice speed boosts, I need to learn how to use it
properly rather than just my copy and paste from a basic default
config. It's Varnish 2.something so maybe I should upgrade to the
newer version too, but I wasn't even sure how to do that so I need to
do some research.

Thanks all.
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages