Note that there are some explanatory texts on larger screens.

plurals
  1. POngx_pagespeed - Gzip static assets
    primarykey
    data
    text
    <p>I am trying to find the best approach for my nginx box. My goal is, of course, the best possible performance, and the best loading times for my users.</p> <p>So I was load testing my nginx and - with the help of maxim-dounin from nginx forums - found out that my throughput problems was on the fly gzipping of static assets.</p> <p>I'll have to pre-gzip everything on the build process, thats very easy - and do on the fly gzip for dynamic content only with comp level @ 1 or 2, that shoud save some cpu and allow me to serve as many users as possible with aws m1.small ec2 instance.</p> <p>But I also intent to use ngx_pagespeed to optimize these static assets, minify, combine, stuff that ngx_pagespeed does so well. I mean, images I can work around and do jpgoptim and pngoptim on build process, but combining css/js is harder.</p> <p>I am using these ngx_pagespeed config:</p> <pre><code>pagespeed on; pagespeed EnableFilters combine_css,combine_javascript,canonicalize_javascript_libraries,collapse_whitespace,convert_meta_tags,dedup_inlined_images,flatten_css_imports,inline_import_to_link,inline_css,inline_javascript,rewrite_javascript,remove_comments,rewrite_css,rewrite_images,convert_gif_to_png,recompress_png,convert_jpeg_to_progressive,strip_image_color_profile,strip_image_meta_data,insert_image_dimensions; pagespeed JpegRecompressionQuality 80; pagespeed FileCacheSizeKb 256000; #256mb pagespeed FileCacheCleanIntervalMs 3600000; pagespeed FileCacheInodeLimit 500000; pagespeed FileCachePath /run/shm/nginx/pagespeed_cache; pagespeed Statistics on; pagespeed StatisticsLogging on; pagespeed LogDir /var/log/pagespeed; pagespeed LowercaseHtmlNames on; </code></pre> <p>Any ideias on how ngx_pagespeed works with nginx gzip_static? I mean, as far as my understaing go, ngx_pagespeed is running 'in front' of nginx, as it caches everything it optimizes to tmpfs. If the server got a hit for a already optimized asset it servers from tmpfs, and I looked for gzipped files on the cache folder and could not find any. First of all, ngx_pagespeed does its own gzipping? It does it on the fly or it cache gzipped version?</p> <p>How does it go when it receives an already gzipped asset from nginx (gzip_static on)? Does it have to unzip and then gzip again after optimization?</p> <p>How can I have the best of both worlds - serving pre-compressed static assets and ngx_pagespeed optimizations?</p> <p>Thanks alot and best regards.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COWhy are you using gzip_static? If it is because the CPU cost of gzipping is too high, then ngx_pagespeed will definitely be too expensive for your setup. ngx_pagespeed adds quite a bit more CPU use than gzip.
      singulars
    2. COThanks for the help. CPU is a limitation, yes, but also is network throughput of the ec2 machine which is 30.000 KB/s, so I need to balance things. I am using gzip_static in order to get best compression level without the waste of cpu. I know pagespeed adds alot of cpu usage but I really would like to have my assets optimized, combined, minified, and I dont have control over the source code. My question is - ngx_pagespeed is caching my static optimized assets to tmpfs. Every time the user hits the optimized asset, ngx_pagespeed gzips it? Or it keeps a gzipped asset on the cache?
      singulars
    3. COFrom my testing, it should be faster. For instance, when a user hits a asset like [/css/A.print.css.pagespeed.cf.54Itr6v-Y8.css], it is fetched from tmpfs cache and server directly. But the throughput is not that good compared to nginx serving static content. So my question has changed a little bit since I have done some testing and reading about this. What does ngx_pagespeed does when [/css/A.print.css.pagespeed.cf.54Itr6v-Y8.css] gets hit and the asset is in cache? Does it serve it directly? Does it gzip and serve? Does it keep a gzipped version? Do I have control over this?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload