2

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?

Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96
  • If you'd like help debugging this, please email us with your site URL at the https://groups.google.com/forum/#!forum/ngx-pagespeed-discuss discussion list. We'll need more information to figure out why this isn't working. – sligocki Sep 12 '13 at 13:55
  • Are you using ssl and/or spdy? – Robert de W Mar 30 '14 at 12:58

1 Answers1

2

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.

oschaaf
  • 281
  • 1
  • 7
  • Do you recommend to short the js file name? pagespeed splits my 7 js into 3 files. – DjangoPy Jan 10 '16 at 12:23
  • That depends on the reason that PageSpeed splits the files over three combined files. You could add ?PageSpeedFilters=+debug to the querystring, and then PageSpeed may write html comments about why it may be splitting them up. It might be that the contents of the combined files would grow too large if it would combine them all into a single file, in which case having multiple files could be the better option. – oschaaf Jan 11 '16 at 14:45