
Google Releases mod_pagespeed for Apache - mike-cardwell
http://googlewebmastercentral.blogspot.com/2010/11/make-your-websites-run-faster.html
======
mike-cardwell
There are some very interesting filters:

<http://code.google.com/speed/page-speed/docs/filters.html>

It will automatically strip inline css and js out of a html page and then
create links to an external version. It will automatically set very long cache
times. It minifies css and javascript on the fly, strips whitespace and
comments from the html.

Then for images, it automatically rescales them, strips out meta data and
recompresses. It even converts img tags to use data: uris when it's safe and
efficient to do so.

I love it.

------
jellicle
That's pretty cool, though the biggest slowdown for most sites are all of the
third-party scripts being loaded from remote servers. If people really
realized how much page speed matters in usability, they would be loathe to add
in all the scripts from facebook and digg and google and 12 different
analytics services.

~~~
tropin
My adsense scripts almost always freeze my webs waiting for them to load.

Do you fellow HNers know any way to speed up them or at least load them in the
background?

~~~
asolove
Put script tags at the end of the body, not in the header. If you still have a
problem, dynamically add the script tags after the page has already loaded and
displayed.

~~~
tropin
???

Could you share any sample of adsense with scripts in the header? Also, do you
know any way to load dynamically the scripts?

Google seems to be full of people trying to do it to no avail.

~~~
bentlegen
Google's asynchronous tracking snippet:

[http://code.google.com/apis/analytics/docs/tracking/asyncTra...](http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html)

~~~
lamnk
Did you read the parent comment ? He asked about adsense script, not analytics
tracking code.

------
qeorge
Regarding 'Outlining CSS', there's also a risk of breaking sites that depend
on the specificity rules of CSS[1].

I think this should be added to the risks list for this filter[2]. Does anyone
know how to ping Google about such things?

[1] [http://www.molly.com/2005/10/06/css2-and-
css21-specificity-c...](http://www.molly.com/2005/10/06/css2-and-
css21-specificity-clarified/) [2] [http://code.google.com/speed/page-
speed/docs/filter-css-outl...](http://code.google.com/speed/page-
speed/docs/filter-css-outline.html)

~~~
paulirish
<http://groups.google.com/group/mod-pagespeed-discuss> or
<http://code.google.com/p/modpagespeed/issues/list>

~~~
qeorge
Great, thank you! Reported here:

[http://groups.google.com/group/mod-pagespeed-
discuss/t/6bdf2...](http://groups.google.com/group/mod-pagespeed-
discuss/t/6bdf27584dced4f1)

------
jamesbressi
Ask HN:

I'm sure there is going to be tons of positives to this from the community,
many I can identify myself, but can someone list some NEGATIVEs that may arise
by using this?

~~~
pornel
Each of the filters mentions risks:

<http://code.google.com/speed/page-speed/docs/filters.html>

This is a tool that mindlessly applies optimisations that are lossy or change
behavior of the page. Sometimes it may break things (e.g. I use
`input[type=text]` selector in my CSS, and removal of "redundant"
`type="text"` attribute from source would break it).

It also wastes some processing time on applying on-the-fly code changes you
could do yourself in the source.

If you follow performance best practices, you may optimize pages better
yourself (you need to judge what is better to inline, what can be made async.
Simple heuristics of this module uses may be too crude).

~~~
mike-cardwell
Would it? I thought the type defaulted to "text" if missing. I'd be surprised
if css selectors didn't recognise that...

~~~
pornel
CSS sees DOM attributes (what you get from element.getAttribute('type')), and
not DOM properties (element.type).

These are different things kept roughly in sync by setters/getters (called
"reflected properties" in HTML spec).

The `type` attribute is also supposed to have default value implied by the
DTD, but that could only work in _"validating"_ SGML/XML parsers (which
browsers aren't).

~~~
mike-cardwell
I didn't know that. I tested it myself and you're right. The "Elide
Attributes" filter seems fairly pointless anyway. I can't imagine it making
that much of a difference in performance even if it was safe.

------
hippich
I would use this to quickly test any possible enhancements could be done to
site in order to improve performance, but later - turn it off and implement
everything in code.

------
andrewingram
I love the idea of this, but these days I always have something else sitting
in front of apache (usually nginx), it seems like this is where i'd want a
module like this to be running.

If apache rewrites the html with such things like temporary optimized versions
of files, nginx presumably won't know anything about serving them, so it'll
break (date urls being an exception here I guess).

For things like media, I really want to keep apache out of the loop
completely.

------
lamnk
Doesn't matter. I ditched Apache completely for nginx and didn't look back
since then. Every apps get proxied through nginx: PHP scripts run as FastCGI
(php-fpm), Rails and Sinatra apps run on Unicorn ...

------
Goosey
This made me realize just how strongly Google is tied to the success of 'the
internet' vs the traditional desktop. There isn't much in their strategy that
doesn't make sense if you stop trying to figure out how it ties into
seach/advertising and if you see how it just enhances the internet as a whole.

edit: of course enhancing the internet increases the number and frequency of
people interacting with their search, adwords on pages, and feeling
comfortable with web apps (helping create lead for Google Apps B2B)

------
gawker
Would love something like this for nginx - Apache's just using too much
memory.

~~~
necro
Most of these are micro optimizations that matter most on a larger site. Most
large site do not use Apache for static content. I agree, nginx would be a
better first choice for a module.

One thing that may not be obvious about minimization is that it does not yield
much size reduction when coupled with gzip. You may see 30% decrease in size
with minimization on the plain file, but when you gzip both the plain and
minimized you may only see a difference for a couple of hundred bytes. If you
are worried about speed, you should be using gzip for static content.

~~~
56quarters
I've found using minimization to give up 40% smaller files even after gzip.
Even so, combining multiple JS or CSS files into single one and using image
sprites will probably be your biggest win.

------
wanderr
Has anyone found/done any benchmarks showing what performance impact running
mod_pagespeed will have on your /server/?

I'm all for optimizing the crap out of page serving, but if this is going to
double our Apache load, a) I'd like to know about it ahead of time and b) it
might be worth just applying optimizations by hand.

------
mootothemax
Somewhat ironically, one of the biggest slowdowns on my websites has been
using Google Analytics. I only realised this after I switched completely to my
own installation of Piwik - give it a try, the load times can be quite
surprising.

~~~
trickjarrett
Were you using the asyncronous Analytics code?

~~~
mootothemax
Nah, and to be fair, this was a while ago - when the async stuff had barely
been released in beta. I hope the situation's improved somewhat now because of
it :)

~~~
trickjarrett
The async code makes a world of difference, it definitely improved things for
me and my sites.

------
ovi256
Google has been accused by free software luminaries that, while it respects
the letter of the GPL, it does not respect the spirit of the license, as it
does not share its optimized versions of the Linux kernel, Apache server, and
many other GPL software. Of course, as it's GPL, not AGPL, they are not
legally in the wrong. This nice piece of infrastructure is a step forward,
let's hope they release more of their custom infrastructure.

~~~
wmf
Does Google use this internally? I got the impression that it was written
specifically for external use.

~~~
stanleydrew
I would think they almost certainly don't use this internally given that they
don't run Apache for any of their user-facing applications.

------
apgwoz
For those worried that it might break something on their site, a word of
advice. You shouldn't expect _anything_ to "just work," and should, like any
technology that you make use of, _evaluate_ and _test_ it out to see if it's
right for you.

There's no details on it, but I wonder if GoDaddy has some plan to provide a
way to turn specific things off. If not, this sounds like it could be a
disaster.

------
Yrlec
This looks very promising! Microsoft has similar features (although not
officially supported yet) for ASP.NET:
<http://aspnet.codeplex.com/releases/view/50869>
<http://aspnet.codeplex.com/releases/view/35893>

------
bwooceli
All great ideas. I'm in a bit of a knowledge-base limbo where I spend just
enough time setting up my server so that it survives a load test. I use nginx
as my daily driver; I think I'll try to level up some admin skill and try to
apply some of these principles to my setup. Who knows, maybe I'll do a write
up.

------
ochronus
Some concerns about this module here: <http://blog.mostof.it/mod_pagespeed/>

Don't let developers be blinded by an automatic optimizer.

------
dchest
Does it cache optimized images or regenerates them for every request?

Edit: Yes, it does:

 _In order to rewrite resources, mod_pagespeed must cache them on the server._

------
CharlesPal
Has anyone been able to get this working with a web server running cPanel?

------
robk
It's sad/embarrassing they don't have a Chrome plugin for this but do offer
Firefox.

~~~
blasdel
Screw that, they've got their priorities straight.

It's awesome that they don't treat 'uncaptured synergy' as a release blocker
like Microsoft would have.

