# NGINX CSS optimizer module?

**URL:** <https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722>\
**Category:** NGINX\
**Created:** [January 13, 2012, 6:48pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722 "2012-01-13T18:48:25Z")\
**Posts on this page:** 9\
**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:** [January 13, 2012, 6:48pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/1 "2012-01-13T18:48:25Z")

</div>

Hi all,

We have been using NGINX for a year now with great results, so thanks to  
everyone who has made this project so successful!

I am looking for a feature which I hope NGINX supports, and that is  
optimization of serving CSS files, specifically around minimizing and  
resolving @import statements server side.

For instance, to better manage the hundreds of css files we have, we  
started breaking them up and using the @import directive. Obviously this  
slows things down quite a bit because the browser has to make lots of  
additional requests.

I am looking for a way to have NGINX automatically resolve all @imports  
so  
when it servers a CSS file so it has no dependencies.

Any feedback would be much appreciated!

Thanks,

Casey

## –

Casey J.  
easyDITA a product of Jorsek LLC  
“CaseyDJordan” on LinkedIn, Twitter & Facebook  
(585) 348 7399

> **[Heretto](https://heretto.com/)**
>
> Heretto is a content operations platform for knowledge management that turns your product content into engaging digital experiences.

This message is intended only for the use of the Addressee(s) and may  
contain information that is privileged, confidential, and/or exempt from  
disclosure under applicable law. If you are not the intended recipient,  
please be advised that any disclosure copying, distribution, or use of  
the information contained herein is prohibited. If you have received  
this communication in error, please destroy all copies of the message,  
whether in electronic or hard copy format, as well as attachments, and  
immediately contact the sender by replying to this e-mail or by phone.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 7:09pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/2 "2012-01-13T19:09:00Z")

</div>

On Friday 13 January 2012 21:47:32 Casey J. wrote:  
[…]

> I am looking for a way to have NGINX automatically resolve all @imports so  
> when it servers a CSS file so it has no dependencies.
> 
> Any feedback would be much appreciated!

Do you want to do such resource-intensive task on every request?

wbr, Valentin V. Bartenev

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 7:11pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/3 "2012-01-13T19:11:36Z")

</div>

Ideally, on production server it would cache the result and serve that  
on  
all following requests.

However, on development servers we would need to disable caching of the  
files so that we could see our changes take effect in real time.

Thanks,

Casey

On Fri, Jan 13, 2012 at 1:08 PM, Valentin V. Bartenev [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > additional requests.  
> > wbr, Valentin V. Bartenev
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

## –

Casey J.  
easyDITA a product of Jorsek LLC  
“CaseyDJordan” on LinkedIn, Twitter & Facebook  
(585) 348 7399

> **[All-In-One Content Ops Tool for Technical Documentation | Heretto](https://www.heretto.com)**
>
> Content operations tool for technical documentation teams—streamline authoring, management, and publishing. Discover how Heretto boosts efficiency and consistency.

This message is intended only for the use of the Addressee(s) and may  
contain information that is privileged, confidential, and/or exempt from  
disclosure under applicable law. If you are not the intended recipient,  
please be advised that any disclosure copying, distribution, or use of  
the information contained herein is prohibited. If you have received  
this communication in error, please destroy all copies of the message,  
whether in electronic or hard copy format, as well as attachments, and  
immediately contact the sender by replying to this e-mail or by phone.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 11:20pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/4 "2012-01-13T23:20:51Z")

</div>

James,

Thanks for the suggestion and we do already do this for a good deal of  
our  
application css.

The CSS I am talking about though is more dynamic, and is actually part  
of  
publishing pipelines that users of our software configure and use when  
the  
server is running. Users will be uploading new CSS, making changes etc,  
all  
in real time to influence published outputs of their content.

So it’s not ideal to compile this on deployment, which is a main reason  
I  
need a more dynamic solution.

Thanks,

Casey

On Fri, Jan 13, 2012 at 4:54 PM, James C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> files into a single file, and \>make install\< installs that into the

## –

Casey J.  
easyDITA a product of Jorsek LLC  
“CaseyDJordan” on LinkedIn, Twitter & Facebook  
(585) 348 7399

> **[All-In-One Content Ops Tool for Technical Documentation | Heretto](https://www.heretto.com)**
>
> Content operations tool for technical documentation teams—streamline authoring, management, and publishing. Discover how Heretto boosts efficiency and consistency.

This message is intended only for the use of the Addressee(s) and may  
contain information that is privileged, confidential, and/or exempt from  
disclosure under applicable law. If you are not the intended recipient,  
please be advised that any disclosure copying, distribution, or use of  
the information contained herein is prohibited. If you have received  
this communication in error, please destroy all copies of the message,  
whether in electronic or hard copy format, as well as attachments, and  
immediately contact the sender by replying to this e-mail or by phone.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 11:46pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/5 "2012-01-13T23:46:13Z")

</div>

On Sat, Jan 14, 2012 at 12:20 AM, Casey J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I am looking for a feature which I hope NGINX supports, and that is  
> optimization of serving CSS files, specifically around minimizing and  
> resolving @import statements server side.
> 
> For instance, to better manage the hundreds of css files we have, we  
> started breaking them up and using the @import directive. Obviously this  
> slows things down quite a bit because the browser has to make lots of  
> additional requests.

> Ideally, on production server it would cache the result and serve  
> that on all following requests.

Pretty trivial task for nginx-perl. Shouldn’t take long to implement if  
you are  
already familiar with embedded perl.

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 10:56pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/6 "2012-01-13T22:56:09Z")

</div>

> > > > > “CJ” == Casey J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

CJ\> Ideally, on production server it would cache the result and serve  
CJ\> that on all following requests.

CJ\> However, on development servers we would need to disable caching of  
CJ\> the files so that we could see our changes take effect in real time.

A better alternative may be to manage them just like any software  
package. Write a Makefile so that \>make\< links the various src css  
files into a single file, and \>make install\< installs that into the  
served directory.

## -JimC

James C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) OpenPGP: 1024D/ED7DAEA6

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 11:50pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/7 "2012-01-13T23:50:33Z")

</div>

> Pretty trivial task for nginx-perl. Shouldn’t take long to implement if you are  
> already familiar with embedded perl.

P.S. I think even original embedded perl would be enough, depending  
where  
you store users’ files.

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 13, 2012, 11:59pm UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/8 "2012-01-13T23:59:10Z")

</div>

Interesting. I have used perl before but not embedded perl.

I should also mention that NGINX is being used as a proxy server. So it  
would not actually be reading files off the local drive.

Does this effect the use of embedded perl? Any examples you might be  
able  
to point me to?

Thanks,

Casey

On Fri, Jan 13, 2012 at 5:50 PM, Alexandr G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

## –

Casey J.  
easyDITA a product of Jorsek LLC  
“CaseyDJordan” on LinkedIn, Twitter & Facebook  
(585) 348 7399

> **[All-In-One Content Ops Tool for Technical Documentation | Heretto](https://www.heretto.com)**
>
> Content operations tool for technical documentation teams—streamline authoring, management, and publishing. Discover how Heretto boosts efficiency and consistency.

This message is intended only for the use of the Addressee(s) and may  
contain information that is privileged, confidential, and/or exempt from  
disclosure under applicable law. If you are not the intended recipient,  
please be advised that any disclosure copying, distribution, or use of  
the information contained herein is prohibited. If you have received  
this communication in error, please destroy all copies of the message,  
whether in electronic or hard copy format, as well as attachments, and  
immediately contact the sender by replying to this e-mail or by phone.  
Thank you.

---

<div class="post-metadata">

**Author:** ![Casey\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Casey\_J](https://www.ruby-forum.com/u/Casey_J)\
**Post date:** [January 14, 2012, 12:42am UTC](https://www.ruby-forum.com/t/nginx-css-optimizer-module/215722/9 "2012-01-14T00:42:26Z")

</div>

On Sat, Jan 14, 2012 at 12:58 AM, Casey J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I should also mention that NGINX is being used as a proxy server.

Right, that was my first guess.

> Does this effect the use of embedded perl?

It does. You can’t make requests to remote hosts asynchronously from  
original  
embedded perl, but you can from nginx-perl.

> Any examples you might be able to point me to?

Documentation is the only place with simple examples right now:  
[http://zzzcpan.github.com/nginx-perl/Nginx.html#HTTP\_API](http://zzzcpan.github.com/nginx-perl/Nginx.html#HTTP_API)

I understand that you don’t feel like using 3rd party distribution.  
But it won’t  
be a problem, I’m going to generate an addon out of it in the future.
