Question

I have about 14 css sheets and about 12 js files that need to load with my application.

I am using google pagespeed.

Instead of combining 14 sheets into 1 sheet its combining them into 3.

Even javascript combination is not working really well but it is to some extent. No minification there either.

I tried reading docs but can not really find much clue.

ALso it is not doing any minification. It is working but only to some extent

Here is all the code that has to do with this:

   pagespeed on;

   # Needs to exist and be writable by nginx.
   pagespeed FileCachePath /var/ngx_pagespeed_cache;
   pagespeed RewriteLevel PassThrough;
   pagespeed EnableFilters     add_head,combine_css,convert_meta_tags,convert_png_to_jpeg,extend_cache,fallback_rewrite_css_urls,flatten_css_imports,inline_css,inline_import_to_link,inline_javascript,rewrite_css,rewrite_images,rewrite_javascript,rewrite_style_attributes_with_url;
   pagespeed EnableFilters combine_javascript,remove_comments,collapse_whitespace;

   # Ensure requests for pagespeed optimized resources go to the pagespeed handler
   # and no extraneous headers get set.
   location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
     add_header "" "";
   }
   location ~ "^/ngx_pagespeed_static/" { }
   location ~ "^/ngx_pagespeed_beacon$" { }
   location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
   location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }

What filter have I missed?

Était-ce utile?

La solution

The urls that ngx_pagespeed can generate are bounded by a setting called 'MaxSegmentLength' [1]. There are good reasons for that. This implies that the amount of files that can be combined into a single url is bounded as well. That might be what is causing the 14 css files to be combined into 3 urls, instead of 1.

Skipping minification of javascript can be because of these things: - The javascript was diagnosed to be introspective [2]. - The javascript contains parse errors.

It might be worth having a look at nginx's error.log, and check the configuration loading messages and the output of ngx_pagespeed on the first request in there, to figure out what is wrong.

[1] See "Limiting the maximum generated URL segment length" at https://developers.google.com/speed/pagespeed/module/restricting_urls [2] See "Restricting PageSpeed from rewriting URLs of introspective JavaScript" at the url above.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top