Pagespeedmodule - Build a ressources server - nginx

I use Nginx and I have installed Google PageSpeedModule on one of my domain. This module is really usefull, and easy to use. All CSS and JS are minified, my images are compressed... it has reduced the weight of 500 kb of my pages.
My question is, can I use this module to deliver only ressources ? I create a kind of CDN, containing all my CSS, images, JS... But, I installed Nginx + pagespeedmodule and the module is not working for one image only for example. But it works with an HTML page and compress the images in this page, but can it work with a direct access image ? Thanks.

Yes, you can use InPlaceResourceOptimization to optimize images even if they are not optimized in HTML (Note: That doc says that this is an Apache-only feature, but that's out of date, it works in the latest Nginx as well.). Add this command to your config:
pagespeed InPlaceResourceOptimization on;
Note that the default way that ngx_pagespeed works is by rewriting resources found in HTML. That is the most efficient way to run it. If you only use InPlaceResourceOptimization you will not get some advantages like cache extension and image resizing. However this is a convenient feature if you cannot optimize resources in HTML.

Related

Is css #import google font better than a local copy for site optimization

In terms of site optimization and speed; is it better to include a font locally or use a css #import? (I'm using google's web-fonts)
You will need to do a test on your own. The simplest way to do so is to use a developer tools console in your browser and to check a network section to see how how long it takes for the files to be loaded. It is possible that your web server may dish out files slower or faster than google.
Additionally, some browsers, like Firefox, by default, may not include font files downloaded from a different domain. To make sure your site renders as expected, I would serve font files from within the domain that the user visits.

Drupal 7 cache & css compression affects sub-domains

There is an issue with caching on my website. I used standard in-build cache and css&js compression previously, but now I had to turn it off. Turns out, all js&css code still minified. What's more - it affects sub-domain folders (my host is bluehost) so all sub-domain are also have same problem with scripts.
It's really weird issue. I tried to clear all cache_ tables from Drupal database, as well as everything related to cache from /sites/ folder. Still no result.
Any help will be appreciated.
Perhaps you have used advagg or minify module for that. If so - you need disable them in order to get rid of minification.
I would also recommend to inspect the current css files in browser and check what is the path to it. Doing that you would get better understanding what is going on here.
After disabling minification options on System/Development/Performance page in the actual html source on a page it should change from
into a list of
#import url("http://domain.name/sites/all/modules/admin_menu/admin_menu.css?nlpz6z");

Google mod_pagespeed for ajax loaded content

I`m trying to optimze and convert images using mod_pagespeed and it works very good for all tags in html files. But how could it process images that loaded with js? For example images in slideshows and etc.
Thanks!
mod_pagespeed normally optimizes images and other resources by detecting their URL in the HTML and then replacing the URL with a link to the optimized version. As of mod_pagespeed 1.4.26.1 however, mod_pagespeed includes a feature called In-Place Resource Optimization, which allows resources requested with their original URL to be optimized. This can be used in cases like yours where images are being requested through AJAX. It can be enabled by setting ModPagespeedInPlaceResourceOptimization on in your config file, and have a look at the documentation linked above for more details.
Google's mod_pagespeed module only parses HTML files for images, and then optimizes them. You would have to have the images loaded via the HTML file, and then referenced/shown to the client via javascript. (Have the images hidden by default).

mod_pagespeed won't combine CSS and JS

I've installed mod_pagespeed on our server but it won't combine my CSS and JS on our website oktoberfest.it. Obviously I've activated combine_css, combine_javascript and PassThrough in filters in pagespeed.conf file.
I've also read that mod_pagespeed can't combine CSS files that contains CSS3 directives, but in my Apache's log file, after enabling LevelLog debug of course, there aren't any error or infos about failures in combining. Neither CSS neither JS.
I've tried to:
Readd CoreFilters
Reboot Apache
Delete mod_pagespeed cache with touch
/var/mod_pagespeed/cache/cache.flush
Deactivate all filters except combine_css and combine_javascript
I've check that folders indicated in .config file are CHMOD 777
I don't know what to do now. I'm done with ideas. I really want this mod_pagespeed features work with our website, we have 40 requests of CSSs and JSs that come from plugins that we can not manage.
What do you suggest me to do?
For CSS Combine
As you are using Wordpress, you need to add a Function in
function.php of Wordpress.
function remove_style_id($link) {
return preg_replace("/id='.*-css'/", "", $link);
}
add_filter('style_loader_tag', 'remove_style_id');
Wordpress writes ID="" Tags into the css link which pagespeed doesn´t like. So it will be ignored.
BUT It "could" cause Problems with a Plugin if a Javascript calls the ID, but regular no one will do it that way. So you´ll be safe.
You can permit IDs for css combining as of version 1.12.34.1, have a look at the documentation.
As wordpress adds -css to any ID, you can just add:
Apache:
ModPagespeedPermitIdsForCssCombining *-css
Nginx:
pagespeed PermitIdsForCssCombining *-css;
There appear to be a few issues preventing mod_pagespeed from combining resources on your site. First of all, many of your CSS files have id attributes, which will prevent the combine_css filter from functioning. HTML generally expects elements to have a single id attribute, and it's not clear what that should be if those CSS files are combined.
That doesn't explain why mod_pagespeed does not seem to be rewriting any CSS or JS resources on your page though. mod_pagespeed is able to rewrite the HTML, for example www.oktoberfest.it/?ModPagespeedFilters=collapse_whitespace is able to remove whitespace from the page. The issue is likely that mod_pagespeed is not able to fetch these resources internally. This can happen for a number of reasons, but look in your apache error_log for messages related to SERF.
The best fix for fetch related failures is to use the ModPagespeedLoadFromFile directive if your environment will allow it. Also have a look at this FAQ entry, which explains the problem. You can also try updating to beta release 1.4.26.1 or later, which includes a workaround for common loopback fetch errors.

Nginx and Watermarking

I use ngx_http_image_filter_module module for serving images in my project.
Everything works perfectly. And now I want to dynamically put watermarks on images.
I can't put them on upload because image sizes are often being changed.
So, is that possible with nginx?
Try this patch. I found it through internet.
It is allow to nginx to apply watermark's. This implementation only works with using function, which change size of image.

Resources