Get the most out of your Centmin Mod LEMP stack
Become a Member

Nginx PageSpeed Nginx Pagespeed - ngx_pagespeed module

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by eva2000, May 25, 2014.

  1. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
    A major addition to the Centmin Mod Nginx configuration is Nginx Pagespeed - ngx_pagespeed module as outlined at http://centminmod.com/nginx_ngx_pagespeed.html.

    There's just so much information, it's best to read it from the beginning from above linked page.

    Brief info listed below.

    Google recently announced the release of Nginx Pagespeed, ngx_pagespeed module - the Nginx equivalent to Apache's mod_pagespeed. Reminder, it's still a beta release, so be sure to keep up to date with Nginx Pagespeed bugs and issues as well 'Using the PageSpeed Module' guide.
    1. What is ngx_pagespeed and why install the module ?
    2. Google I/O 2013 - Video
    3. Introduction to ngx_pagespeed on Centmin Mod
    4. How to install and configure ngx_pagespeed on Centmin Mod Nginx ?
    5. How to exclude specific urls, files, directories from ngx_pagespeed ? (added May 3rd, 2014)
    6. How to disable ngx_pagespeed integration in Centmin Mod Nginx ?
    7. How to upgrade ngx_pagespeed on Centmin Mod ?
    8. ngx_pagespeed config files
    9. ngx_pagespeed statistics page
    10. ngx_pagespeed PageSpeed Console (added July 18th, 2013)
    What is ngx_pagespeed and why install the module ?


    Google I/O 2013 - Video


    Ilya Grigorik presentation video at Google I/O 2013 explaing Google Pagespeed - Automating Performance Best Practices with PageSpeed. If after watching that video, you get the itch to test your own web site's PageSpeed scores, check out one of my blog articles titled - Web site page loading speed optimization online tools & tests, which lists a number of online page speed and analysis tools - many I use myself.



    Introduction to ngx_pagespeed on Centmin Mod

    I decided to add ngx_pagespeed module support to Centmin Mod v1.2.3-eva2000.01 beta release. There are 4 variables in centmin.sh which controls whether ngx_pagespeed module support is added:
    • NGINX_PAGESPEEDGITMASTER=y. Setting to yes will override the below variable's version number and grab the lastest master source repository fromhttps://github.com/pagespeed/ngx_pagespeed. This setting was added as some specific version builds had bugs which were not fixed in the specific version but were fixed in master repository. Setting this to yes would allow you to get the latest fixes which don't exist in version specific versions. If you have this set to yes and Nginx fails to compile, it could be a bug in master repository, so set it to no NGINX_PAGESPEEDGITMASTER=n and specify a specific version below and re-run centmin.sh menu option #4 to recompile Nginx
    • NGINX_PAGESPEED=y. Setting NGINX_PAGESPEED=n will disable ngx_pagespeed module when you next run Nginx upgrade via menu option #4.
    • NGXPGSPEED_VER='1.7.30.4-beta' - sets the ngx_pagespeed version to install
    • NGINX_PAGESPEEDPSOL_VER='1.7.30.4' - sets the Pagespeed Optimization Library version - which as of ngx_pagespeed 1.5.27.3 beta is no longer included with main ngx_pagespeed module download.
    While ngx_pagespeed module is installed, the default ngx_pagespeed state is turned off. After ngx_pagespeed module is added to Nginx, you'll need to enable it via Centmin Mod command line shortcut within SSH telnet type:
    Code:
    pscontrol on
    
    To turn off ngx_pagespeed:
    Code:
    pscontrol off
    
     
  2. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
    Last edited: May 26, 2014
  3. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
    ngx_pagespeed 1.8.31-2 beta global pagespeed admin (/pagespeed_global_admin/) and console stats can be enabled same way as outlined at http://centminmod.com/nginx_ngx_pagespeed.html#pagespeedconsole

    i.e.

    Code:
    timestamp_:                                            1401007809749
    cache_time_us:                                               1351875
    cache_hits:                                                     2883
    cache_misses:                                                    398
    cache_backend_hits:                                             3189
    cache_backend_misses:                                             92
    cache_fallbacks:                                                   3
    cache_expirations:                                               148
    cache_inserts:                                                   468
    cache_deletes:                                                     0
    instrumentation_filter_script_added_count:                         0
    cache_extensions:                                                711
    not_cacheable:                                                     0
    critical_css_beacon_filter_script_added_count:                   240
    critical_css_no_beacon_due_to_missing_data:                        0
    critical_css_skipped_due_to_charset:                               0
    critical_images_beacon_filter_script_added_count:                318
    css_combine_opportunities:                                       895
    css_file_count_reduction:                                        306
    css_filter_blocks_rewritten:                                     166
    css_filter_parse_failures:                                         0
    css_filter_fallback_rewrites:                                      0
    css_filter_fallback_failures:                                      0
    css_filter_rewrites_dropped:                                       0
    css_filter_total_bytes_saved:                                 220030
    css_filter_total_original_bytes:                            10019598
    css_filter_uses:                                                1673
    flatten_imports_charset_mismatch:                                  0
    flatten_imports_invalid_url:                                       0
    flatten_imports_limit_exceeded:                                  110
    flatten_imports_minify_failed:                                     0
    flatten_imports_recursion:                                         0
    flatten_imports_complex_queries:                                   0
    num_css_inlined:                                                 432
    css_imports_to_links:                                              0
    css_elements_moved:                                               71
    num_css_used_for_critical_css_computation:                       740
    num_css_not_used_for_critical_css_computation:                  1125
    num_dedup_inlined_images_candidates_found:                         0
    num_dedup_inlined_images_candidates_replaced:                      0
    domain_rewrites:                                                   0
    google_analytics_page_load_count:                                  0
    google_analytics_rewritten_count:                                  0
    font_service_input_resource_hit:                                   0
    font_service_input_resource_recent_fetch_failure:                  0
    font_service_input_resource_recent_uncacheable_treated_as_miss:    0
    font_service_input_resource_recent_uncacheable_treated_as_failure: 0
    font_service_input_resource_miss:                                  4
    image_file_count_reduction:                                        0
    image_rewrites:                                                   46
    image_resized_using_rendered_dimensions:                           0
    image_norewrites_high_resolution:                                  0
    image_rewrites_dropped_intentionally:                              6
    image_rewrites_dropped_decode_failure:                             0
    image_rewrites_dropped_mime_type_unknown:                          0
    image_rewrites_dropped_server_write_fail:                          0
    image_rewrites_dropped_nosaving_resize:                            0
    image_rewrites_dropped_nosaving_noresize:                          6
    image_rewrites_dropped_due_to_load:                                0
    image_rewrites_squashing_for_mobile_screen:                        0
    image_rewrite_total_bytes_saved:                               61224
    image_rewrite_total_original_bytes:                           104248
    image_rewrite_uses:                                             5539
    image_inline:                                                   2023
    image_webp_rewrites:                                              45
    image_rewrite_latency_total_ms:                                  160
    image_ongoing_rewrites:                                            0
    image_webp_conversion_gif_timeouts:                                0
    image_webp_conversion_png_timeouts:                                0
    image_webp_conversion_jpeg_timeouts:                               0
    image_webp_alpha_timeouts:                                         0
    image_webp_opaque_timeouts:                                        0
    in_place_oversized_opt_stream:                                     0
    in_place_uncacheable_rewrites:                                     0
    inserted_ga_snippets:                                              0
    javascript_blocks_minified:                                     1643
    javascript_libraries_identified:                                   0
    javascript_minification_failures:                                  0
    javascript_total_bytes_saved:                                 150494
    javascript_total_original_bytes:                             3317585
    javascript_minify_uses:                                         1645
    javascript_reducing_minifications:                              1637
    javascript_minification_disabled:                                  0
    javascript_did_not_shrink:                                         1
    javascript_failed_to_write:                                        0
    js_file_count_reduction:                                        1088
    num_js_inlined:                                                   64
    num_local_storage_cache_candidates_found:                          0
    num_local_storage_cache_stored_total:                              0
    num_local_storage_cache_stored_images:                             0
    num_local_storage_cache_stored_css:                                0
    num_local_storage_cache_candidates_added:                          0
    num_local_storage_cache_candidates_removed:                        0
    converted_meta_tags:                                             465
    split_html_beacon_filter_script_added_count:                       0
    num_rewrites_abandoned_for_lock_contention:                        0
    num_distributed_rewrite_successes:                                 0
    num_distributed_rewrite_failures:                                  0
    num_distributed_metadata_failures:                                 0
    num_deadline_alarm_invocations:                                    0
    url_input_resource_hit:                                          362
    url_input_resource_recent_fetch_failure:                         158
    url_input_resource_recent_uncacheable_treated_as_miss:             0
    url_input_resource_recent_uncacheable_treated_as_failure:          0
    url_input_resource_miss:                                         236
    url_trims:                                                         0
    url_trim_saved_bytes:                                              0
    resource_url_domain_acceptances:                               22468
    resource_url_domain_rejections:                                 7029
    rewrite_cached_output_missed_deadline:                          1251
    rewrite_cached_output_hits:                                    15801
    rewrite_cached_output_misses:                                   1611
    resource_404_count:                                             4505
    slurp_404_count:                                                   0
    total_page_load_ms:                                                0
    page_load_count:                                                   0
    resource_fetches_cached:                                        2521
    resource_fetch_construct_successes:                              115
    resource_fetch_construct_failures:                                 0
    num_cache_control_rewritable_resources:                          924
    num_cache_control_not_rewritable_resources:                      311
    num_flushes:                                                     482
    num_fallback_responses_served:                                     0
    num_proactively_freshen_user_facing_request:                       0
    num_fallback_responses_served_while_revalidate:                    0
    num_conditional_refreshes:                                         0
    ipro_served:                                                       0
    ipro_not_in_cache:                                                 0
    ipro_not_rewritable:                                               0
    downstream_cache_purge_attempts:                                   0
    successful_downstream_cache_purges:                                0
    total_fetch_count:                                              2510
    total_rewrite_count:                                             482
    num_rewrites_executed:                                           792
    num_rewrites_dropped:                                              0
    num_resource_fetch_successes:                                     87
    num_resource_fetch_failures:                                     153
    html-worker-queue-depth:                                           0
    rewrite-worker-queue-depth:                                        0
    low-priority-worked-queue-depth:                                   0
    cache_batcher_dropped_gets:                                        0
    critical_images_valid_count:                                     373
    critical_images_expired_count:                                    34
    critical_images_not_found_count:                                  75
    critical_css_valid_count:                                          0
    critical_css_expired_count:                                        0
    critical_css_not_found_count:                                      0
    critical_selectors_valid_count:                                  337
    critical_selectors_expired_count:                                 35
    critical_selectors_not_found_count:                              105
    serf_fetch_request_count:                                        240
    serf_fetch_bytes_count:                                      2187548
    serf_fetch_time_duration_ms:                                     345
    serf_fetch_cancel_count:                                           0
    serf_fetch_active_count:                                           0
    serf_fetch_timeout_count:                                          0
    serf_fetch_failure_count:                                          0
    serf_fetch_cert_errors:                                            0
    memcache_timeouts:                                                 0
    memcache_last_error_checkpoint_ms:                     1401003355791
    memcache_error_burst_size:                                         0
    file_cache_bytes_freed_in_cleanup:                                 0
    file_cache_cleanups:                                               0
    file_cache_disk_checks:                                            3
    file_cache_evictions:                                              0
    file_cache_write_errors:                                           0
    file_cache_deletes:                                                0
    file_cache_hits:                                                  10
    file_cache_inserts:                                                6
    file_cache_misses:                                                 5
    lru_cache_deletes:                                                 0
    lru_cache_hits:                                                    0
    lru_cache_inserts:                                                 0
    lru_cache_misses:                                                  0
    shm_cache_deletes:                                                 0
    shm_cache_hits:                                                12126
    shm_cache_inserts:                                              1576
    shm_cache_misses:                                               1461
    memcached_async_deletes:                                           0
    memcached_async_hits:                                           3372
    memcached_async_inserts:                                        1857
    memcached_async_misses:                                         1366
    memcached_blocking_deletes:                                        0
    memcached_blocking_hits:                                        1009
    memcached_blocking_inserts:                                     1369
    memcached_blocking_misses:                                       914
    compressed_cache_corrupt_payloads:                                 0
    compressed_cache_original_size:                                    0
    compressed_cache_compressed_size:                                  0
    pcache-cohorts-beacon_cohort_deletes:                              0
    pcache-cohorts-beacon_cohort_hits:                               787
    pcache-cohorts-beacon_cohort_inserts:                           1080
    pcache-cohorts-beacon_cohort_misses:                             370
    pcache-cohorts-dom_deletes:                                        0
    pcache-cohorts-dom_hits:                                         228
    pcache-cohorts-dom_inserts:                                      295
    pcache-cohorts-dom_misses:                                       549
    ipro_recorder_resources:                                           0
    ipro_recorder_inserted_into_cache:                                 0
    ipro_recorder_not_cacheable:                                       0
    ipro_recorder_failed:                                              0
    ipro_recorder_dropped_due_to_load:                                 0
    ipro_recorder_dropped_due_to_size:                                 0
    current-fetch-queue-size:                                          0
    queued-fetch-count:                                               33
    dropped-fetch-count:                                               0
    child_shutdown_count:                                              0
    cache_flush_count:                                                 0
    cache_flush_timestamp_ms:                                          0
    statistics_404_count:                                              0
    http_fetches:                                                      0
    http_bytes_fetched:                                                0
    http_approx_header_bytes_fetched:                                  0
    PageSpeed console

    pagespeed_admin_00.png
     
  4. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:44 PM
    Mainline
    10.2
    Version 1.9.32.2 released.
     
  5. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
  6. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:44 PM
    Mainline
    10.2
    Nginx without ngx_pagespeed only consumes 80mb on 8 workers.
    Now when I enable ngx_pagespeed, memory usage climb up to 500mb :whistle:.
    Same with CPU usage, climb up a bit.
     
  7. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
    no free lunch, ngx_pagespeed's ability to load pages faster does consume resources just like varnish cache, fastcgi_cache, redis cache, memcached caching all cache and improve performance by using memory :)

    memory usage might come down a bit if you use ngx_pagespeed as a nginx dynamic module in 123.09beta01

    with persistent config file /etc/centminmod/custom_config.inc setup for
    Code (Text):
    NGXDYNAMIC_NGXPAGESPEED=y
    NGINX_PAGESPEED=y
    
     
  8. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:44 PM
    Mainline
    10.2
    Thanks!
    Installed as dynamic module now.
    I'll observe for an hour :).
     
  9. rdan

    rdan Well-Known Member

    5,419
    1,386
    113
    May 25, 2014
    Ratings:
    +2,167
    Local Time:
    6:44 PM
    Mainline
    10.2
    You are correct :).
    Down to 300+mb usage now :)
    Thanks!
     
  10. jcat

    jcat Member

    140
    20
    18
    Jun 21, 2015
    New Jersey
    Ratings:
    +57
    Local Time:
    6:44 AM
    Failing at upgrading Pagepseed to the latest:

    X-Page-Speed: 1.11.33.0-0

    I'm running 1.2.3-eva2000.09 latest

    I created "/etc/centminmod/custom_config.inc"
    with
    made sure "NGXDYNAMIC_NGXPAGESPEED='y'" but running option 4 still gives you
    X-Page-Speed: 1.11.33.0-0
     
  11. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
    but that is the latest version in centmin.sh and on ngx_pagespeed git repo Releases · pagespeed/ngx_pagespeed · GitHub
     
  12. jcat

    jcat Member

    140
    20
    18
    Jun 21, 2015
    New Jersey
    Ratings:
    +57
    Local Time:
    6:44 AM
    Ah damn, yeah I completely over looked that, I received an email saying:

    "Google has detected that your site is currently running PageSpeed <1.9.32.14 or < 1.10.33.7"
    and was thinking the whole time it was 1.11.33.7 for some reason, MY BAD :) Thanks for the fast response.
     
  13. eva2000

    eva2000 Administrator Staff Member

    50,459
    11,659
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,079
    Local Time:
    8:44 PM
    Nginx 1.25.x
    MariaDB 10.x
    yeah google detection seems a bit delayed or inaccurate if you've enabled in pagespeed.conf the XHeaderValue to mask the version number
    Code (Text):
    #######################################################
    # By default, ngx_pagespeed adds an X-PageSpeed header with a value of the version of
    # ngx_pagespeed being used. This directive lets you specify the value to use instead:
    # pagespeed XHeaderValue "ngx_pagespeed";