# Naive port of mod\_pagespeed for nginx

**URL:** <https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938>\
**Category:** NGINX\
**Created:** [June 6, 2011, 8:25pm UTC](https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938 "2011-06-06T20:25:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 6, 2011, 8:25pm UTC](https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938/1 "2011-06-06T20:25:01Z")

</div>

Hi all,

This is just to announce my naive yet functional port of Google’s  
mod\_pagespeed to nginx.  
I’m not sure I’ll have much time to improve on this, but this might  
interest  
you.

Right now it compiles with the latest stable version of mod\_pagespeed  
and  
does a very simple parsing using the AttrValuesSaverFilter that I found  
in  
the unittests. (it just saves all the html tag attributes found while  
parsing in a string).

The code and instructions to compile it can be found here :

> **[GitHub - mtourne/ngx\_instaweb: Port of Google's mod\_pagespeed for NGINX](https://github.com/mtourne/ngx_instaweb)**
>
> Port of Google's mod\_pagespeed for NGINX. Contribute to mtourne/ngx\_instaweb development by creating an account on GitHub.

Happy hacking,  
Matthieu.

---

<div class="post-metadata">

**Author:** ![Matthieu\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Matthieu\_T](https://www.ruby-forum.com/u/Matthieu_T)\
**Post date:** [June 7, 2011, 6:10am UTC](https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938/2 "2011-06-07T06:10:44Z")

</div>

Matthieu this is great! Nice work! Please keep us posted on this.

-Josh

On Mon, Jun 6, 2011 at 2:23 PM, Matthieu T.

---

<div class="post-metadata">

**Author:** ![Matthieu\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Matthieu\_T](https://www.ruby-forum.com/u/Matthieu_T)\
**Post date:** [June 7, 2011, 6:11am UTC](https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938/3 "2011-06-07T06:11:22Z")

</div>

Out of curiosity, have you defined a mechanism to configure nginx to use  
any  
of the predefined filters? It looks like you were aware of  
RewriteOptions,  
which is the API-based equivalent to pagespeed.conf, but you are not  
using  
it yet in

> <https://github.com/mtourne/ngx_instaweb/blob/master/ngx_http_instaweb_module.cpp>

.

The next step in your nginx integration looks to be resource-handling  
and  
fetching. Specifically, you need to define a way to fetch external HTTP  
resources referenced on a page, and a way to handle fetches for  
rewritten  
resources. We can help you if you have any questions feel free to reach  
out.

Please also check this out:

> **[GitHub - apache/incubator-pagespeed-mod: Apache module for rewriting web...](https://github.com/apache/incubator-pagespeed-mod)**
>
> Apache module for rewriting web pages to reduce latency and bandwidth. - GitHub - apache/incubator-pagespeed-mod: Apache module for rewriting web pages to reduce latency and bandwidth.

We’ve been working along the same lines you have: starting with a  
mod\_pagespeed build, generate a linkable library that has the kernel of  
functionality needed to integrate mod\_pagespeed’s parser & algorithms  
into a  
new platform.

-Josh

---

<div class="post-metadata">

**Author:** ![Matthieu\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Matthieu\_T](https://www.ruby-forum.com/u/Matthieu_T)\
**Post date:** [June 7, 2011, 10:26am UTC](https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938/4 "2011-06-07T10:26:20Z")

</div>

On Mon, Jun 6, 2011 at 6:37 PM, Matthieu T.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> I think I started looking at creating a RewriteOptions object, but got side  
> tracked and this project has been idle for a little while.  
> I just updated it this weekend for the latest mod\_pagespeed, and put it out  
> there.

Cool. As you get time to push this forward, please don’t hesitate to  
ask  
questions.

I like how the instaweb API is designed, and how you provide "backend

> functionalities" through adapter objects (if I remember correctly).  
> With nginx extensive subrequests mechanism, fetching external resources  
> shouldn’t be too difficult.

Thanks! It was a goal up front to make ports like this possible.

This Makefile could definitely help. I was also wondering if there was a

> python lib that could make sense of Google’s internal build files ?

I’m not 100% sure – we are not experts in the .gyp file system  
ourselves  
although there is doc here:  
[http://code.google.com/p/gyp/wiki/InputFormatReference](http://code.google.com/p/gyp/wiki/InputFormatReference). What problem  
are  
you trying to solve?

---

<div class="post-metadata">

**Author:** ![Matthieu\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@Matthieu\_T](https://www.ruby-forum.com/u/Matthieu_T)\
**Post date:** [June 7, 2011, 9:08am UTC](https://www.ruby-forum.com/t/naive-port-of-mod-pagespeed-for-nginx/207938/5 "2011-06-07T09:08:26Z")

</div>

I think I started looking at creating a RewriteOptions object, but got  
side  
tracked and this project has been idle for a little while.  
I just updated it this weekend for the latest mod\_pagespeed, and put it  
out  
there.

I like how the instaweb API is designed, and how you provide “backend  
functionalities” through adapter objects (if I remember correctly).  
With nginx extensive subrequests mechanism, fetching external resources  
shouldn’t be too difficult.

This Makefile could definitely help. I was also wondering if there was a  
python lib that could make sense of Google’s internal build files ?

Thank you!

Matthieu.
