Can there be in whatever way to instantly minify static content after which serve it from the cache instantly? Much like have mod_compress/mod_deflate work? Ideally something I possibly could use in conjunction with compression (since compression includes a more noticeable benefit).

My preference is one thing that actually works with lighttpd however i weren't capable of finding anything, so any web server that may do it might be interesting.

You can test nginx's 3rd party Strip module:

Any module you utilize is simply likely to remove whitespace. You will get a much better result using a minifier that knows whatever you are minifying. e.g. Google's Closure javascript compiler.

It's wise enough to be aware what a flexible is making it's title shorter. A whitespace remover can't do this.

I'd recommend minifying offline unless of course your internet site is really low traffic. But when you need to minify inside your live atmosphere I suggest using nginx's proxy cache. (Sorry however i do not have sufficient status to publish several link)

Or consider memcached to have an in-memory cache or Redis for the similar factor however with disk backup.

If you are using Nginx rather than lighttpd you'll be able to make the most of Nginx's embedded Perl support to leverage the Perl module JavaScript-Minifier to minify and cache JS server-side.

Listed here are the particulars regarding how to accomplish this:

I personally use Microsoft Ajax Minifier which has a C# library to minify js files. I personally use that around the server and offer no more than two minified .js files per page (one "static" one that's exactly the same over the whole site, and something "dynamic" one that's specific to simply that page).

Yahoo's YUI compressor is another simple Java .jar file you could use too.

The key factor, I believe, is to avoid it on the file-by-file basis. You absolutely have to mix the .js files to find the most benefit. For your reason, an "automatic" solution isn't likely to work - since it will always only focus on personal files-by-file basis.

I made the decision to get this done through PHP (mostly because I did not seem like writing a lighttpd module).

My script consumes a question string indicating the kind of the files asked for (js or css), and so the names of individuals files. For instance, on my small site the CSS is added such as this:

<link rel="stylesheet" href="concat.php?type=css&style&blue" ... />

This minifies and concatenates style.css and blue.css

It uses JSMin-PHP and cssmin.

Additionally, it caches the files using XCache whether it's available (since minifying is costly). I really intend to alter the script therefore it does not minify if Xcache is not available, however i have Xcache and that i got bored.

Anyway, if other people wants it, it's here. If you are using mine you will need to alter the isAllowed() function to list out your files (it might be safe to really make it just return true, however it was simple to just list those I wish to allow).