nginx: ngx_pagespeed not using memcache

116 views
Skip to first unread message

shiz

unread,
Jun 30, 2015, 1:56:42 PM6/30/15
to ngx-pagesp...@googlegroups.com
Hi,

I have a server with both apache (port 80) and nginx (port 81) installed.

It is a debian jessie system with custom apache 2.4.10 and nginx 1.9.2

Problem:  The apache server correctly uses memcached for caching, but the nginx server uses the disk cache instead, even though it's configured the same as apache.  Please help me to debug this.  I'd rather like nginx to use memcache for small files.

Memcache settings: /usr/bin/memcached -m 512 -p 11211 -u nobody -l 127.0.0.1

Pagespeed version 1.9.32.4-7251

nginx -V: nginx version: nginx/1.9.2
built with OpenSSL 1.0.1k 8 Jan 2015
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/nginx-auth-pam --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/nginx-dav-ext-module --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/nginx-echo --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/nginx-upstream-fair --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/ngx_http_substitutions_filter_module --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/ngx_pagespeed --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/ngx_cache_purge --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/ngx_openresty/build/ngx_devel_kit-*/ --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/ngx_openresty/build/set-misc-nginx-module-*/ --add-module=/usr/local/src/pagespeed-ngx/nginx-1.9.2/debian/modules/ngx_openresty/build/headers-more-nginx-module-*/


Pagespeed: apache config:
<IfModule pagespeed_module>
    ModPagespeed on
    ModPagespeedDisallow */phpmyadmin/*
    ModPagespeedInheritVHostConfig on
    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
    ModPagespeedFileCachePath            "/var/cache/mod_pagespeed/"
    ModPagespeedLogDir "/var/log/pagespeed"
    ModPagespeedSslCertDirectory "/etc/ssl/certs"
    ModPagespeedMemcachedServers localhost:11211
    ModPagespeedEnableCachePurge on
    ModPagespeedCreateSharedMemoryMetadataCache "/var/cache/mod_pagespeed/" 51200
    ModPagespeedEnableFilters lazyload_images
    ModPagespeedEnableFilters inline_preview_images
    ModPagespeedEnableFilters resize_mobile_images
    ModPagespeedEnableFilters canonicalize_javascript_libraries
    ModPagespeedDisableFilters inline_javascript
    ModPagespeedDisableFilters inline_css
    ModPagespeedEnableFilters insert_dns_prefetch
    ModPagespeedFetchHttps enable
    ModPagespeedFileCacheSizeKb          1024000
    ModPagespeedLRUCacheKbPerProcess     8192
    ModPagespeedLRUCacheByteLimit        16384
    ModPagespeedFileCacheInodeLimit        500000
    ModPagespeedLoadFromFile "http://www.ts-export.com/images/" "/home/tsuchi/public_html/images/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/img/" "/home/tsuchi/public_html/img/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/css/" "/home/tsuchi/public_html/css/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/uploads/" "/home/tsuchi/public_html/uploads/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/img/" "/home/tsuchi/public_html/img/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/css/" "/home/tsuchi/public_html/css/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/uploads/" "/home/tsuchi/public_html/uploads/"
    ModPagespeedLoadFromFile "http://www.ts-export.com/Scripts/" "/home/tsuchi/public_html/Scripts/"
    ModPagespeedLoadFromFile "https://www.ts-export.com/images/" "/home/tsuchi/public_html/images/"
    ModPagespeedLoadFromFile "https://www.ts-export.com/img/" "/home/tsuchi/public_html/img/"
    ModPagespeedLoadFromFile "https://www.ts-export.com/css/" "/home/tsuchi/public_html/css/"
    ModPagespeedLoadFromFile "https://www.ts-export.com/uploads/" "/home/tsuchi/public_html/uploads/"
    ModPagespeedLoadFromFile "https://www.ts-export.com/Scripts/" "/home/tsuchi/public_html/Scripts/"
    ModPagespeedEnableFilters add_instrumentation
    ModPagespeedReportUnloadTime on
    <Location /pagespeed_admin>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler pagespeed_admin
    </Location>
    <Location /pagespeed_global_admin>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler pagespeed_global_admin
    </Location>
    ModPagespeedStatisticsLogging on
    ModPagespeedMessageBufferSize 100000
</IfModule>


Pagespeed:  nginx config:
/etc/nginx# grep -r pagespeed  |grep -v '#'|less
nginx.conf:        pagespeed on;
nginx.conf:        pagespeed FileCachePath /var/cache/mod_pagespeed/;
nginx.conf:        pagespeed MessageBufferSize 100000;
nginx.conf:        pagespeed CreateSharedMemoryMetadataCache /var/cache/mod_pagespeed/ 51200;

        pagespeed Disallow */phpmyadmin/*;    
        pagespeed LogDir /var/log/ngx_pagespeed;
        pagespeed SslCertDirectory /etc/ssl/certs;
        pagespeed MemcachedThreads 1;
        pagespeed MemcachedServers "127.0.0.1:11211";
        pagespeed EnableCachePurge on;
        pagespeed RewriteLevel CoreFilters;
        pagespeed EnableFilters lazyload_images,inline_preview_images,resize_mobile_images,canonicalize_javascript_libraries,insert_dns_prefetch;
        pagespeed EnableFilters add_instrumentation;
        pagespeed DisableFilters inline_javascript,inline_css;
        pagespeed FetchHttps enable;
        pagespeed FileCacheSizeKb          1024000;
        pagespeed LRUCacheKbPerProcess     8192;
        pagespeed LRUCacheByteLimit        16384;
        pagespeed FileCacheInodeLimit        500000;
        pagespeed LoadFromFile http://www.ts-export.com/images/ /home/tsuchi/public_html/images/;
        pagespeed LoadFromFile http://www.ts-export.com/img/ /home/tsuchi/public_html/img/;
        pagespeed LoadFromFile http://www.ts-export.com/css/ /home/tsuchi/public_html/css/;
        pagespeed LoadFromFile http://www.ts-export.com/uploads/ /home/tsuchi/public_html/uploads/;
        pagespeed LoadFromFile http://www.ts-export.com/Scripts/ /home/tsuchi/public_html/Scripts/; 
        pagespeed LoadFromFile https://www.ts-export.com/images/ /home/tsuchi/public_html/images/;
        pagespeed LoadFromFile https://www.ts-export.com/img/ /home/tsuchi/public_html/img/;
        pagespeed LoadFromFile https://www.ts-export.com/css/ /home/tsuchi/public_html/css/;
        pagespeed LoadFromFile https://www.ts-export.com/uploads/ /home/tsuchi/public_html/uploads/;
        pagespeed LoadFromFile https://www.ts-export.com/Scripts/ /home/tsuchi/public_html/Scripts/;
        pagespeed ReportUnloadTime on;
        pagespeed AdminPath /pagespeed_admin;
        pagespeed StatisticsPath /ngx_pagespeed_statistics;
        pagespeed MessagesPath /ngx_pagespeed_message;
        pagespeed ConsolePath /pagespeed_console;

        location ~ "^/ngx_pagespeed_static/" {
        }
        location ~ "^/ngx_pagespeed_beacon$" {
        }
        location ~ ^/pagespeed_admin {
            allow 127.0.0.1;
            deny all;
        }
       location /ngx_pagespeed_statistics {
            allow 127.0.0.1;
            deny all;
        }
        location /ngx_pagespeed_message {
            allow 127.0.0.1;
            deny all;
        }
        location /ngx_pagespeed_message {
            allow 127.0.0.1;
            deny all;
        }
        location /pagespeed_console {
            allow 127.0.0.1;
            deny all;
        }
        location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
                add_header "" "";
        }
        pagespeed StatisticsLogging on;

Apache settings:
Version: 13: on

Filters
ah	Add Head
ai	Add Instrumentation
ij	Canonicalize Javascript library URLs
cc	Combine Css
jc	Combine Javascript
gp	Convert Gif to Png
jp	Convert Jpeg to Progressive
jw	Convert Jpeg To Webp
mc	Convert Meta Tags
pj	Convert Png to Jpeg
di	Delay Images
ec	Cache Extend Css
ei	Cache Extend Images
es	Cache Extend Scripts
fc	Fallback Rewrite Css 
if	Flatten CSS Imports
hw	Flushes html
ii	Inline Images
il	Inline @import to Link
idp	Insert DNS Prefetch
js	Jpeg Subsampling
ll	Lazyload Images
rj	Recompress Jpeg
rp	Recompress Png
rw	Recompress Webp
ri	Resize Images
rm	Resize Mobile Images
cf	Rewrite Css
jm	Rewrite External Javascript
jj	Rewrite Inline Javascript
cu	Rewrite Style Attributes With Url
cp	Strip Image Color Profiles
md	Strip Image Meta Data

Options
  EnableCachePurge (euci)      True
  EnableRewriting (e)          1
  FetchHttps (fhs)             enable
  FileCacheInodeLimit (afcl)   500000
  FileCachePath (afcp)         /var/cache/mod_pagespeed/
  FileCacheSizeKb (afc)        1024000
  LogDir (ald)                 /var/log/pagespeed
  LRUCacheByteLimit (alcb)     16384
  LRUCacheKbPerProcess (alcp)  8192
  MemcachedServers (ams)       localhost:11211
  ReportUnloadTime (rut)       True
  SslCertDirectory (assld)     /etc/ssl/certs
  StatisticsLogging (asle)     True

Domain Lawyer

Invalidation Timestamp: (none)

Nginx settings:
Version: 13: on

Filters
ah	Add Head
ai	Add Instrumentation
ij	Canonicalize Javascript library URLs
cc	Combine Css
jc	Combine Javascript
gp	Convert Gif to Png
jp	Convert Jpeg to Progressive
jw	Convert Jpeg To Webp
mc	Convert Meta Tags
pj	Convert Png to Jpeg
di	Delay Images
ec	Cache Extend Css
ei	Cache Extend Images
es	Cache Extend Scripts
fc	Fallback Rewrite Css 
if	Flatten CSS Imports
hw	Flushes html
ii	Inline Images
il	Inline @import to Link
idp	Insert DNS Prefetch
js	Jpeg Subsampling
ll	Lazyload Images
rj	Recompress Jpeg
rp	Recompress Png
rw	Recompress Webp
ri	Resize Images
rm	Resize Mobile Images
cf	Rewrite Css
jm	Rewrite External Javascript
jj	Rewrite Inline Javascript
cu	Rewrite Style Attributes With Url
cp	Strip Image Color Profiles
md	Strip Image Meta Data

Options
  AdminPath (nap)                              /pagespeed_admin
  AvoidRenamingIntrospectiveJavascript (aris)  True
  BeaconUrl (bu)                               /ngx_pagespeed_beacon
  ConsolePath (ncp)                            /pagespeed_console
  EnableCachePurge (euci)                      True
  EnableRewriting (e)                          1
  FetchHttps (fhs)                             enable
  FileCacheInodeLimit (afcl)                   500000
  FileCachePath (afcp)                         /var/cache/mod_pagespeed/
  FileCacheSizeKb (afc)                        1024000
  LogDir (ald)                                 /var/log/ngx_pagespeed
  LRUCacheByteLimit (alcb)                     16384
  LRUCacheKbPerProcess (alcp)                  8192
  MemcachedServers (ams)                       127.0.0.1:11211
  MemcachedThreads (amt)                       1
  MessagesPath (nmp)                           /ngx_pagespeed_message
  ReportUnloadTime (rut)                       True
  RewriteLevel (l)                             Core Filters
  SslCertDirectory (assld)                     /etc/ssl/certs
  StatisticsLogging (asle)                     True
  StatisticsPath (nsp)                         /ngx_pagespeed_statistics

Domain Lawyer

Invalidation Timestamp: (none)

Jeff Kaufman

unread,
Jun 30, 2015, 2:01:48 PM6/30/15
to ngx-pagesp...@googlegroups.com
The config looks right at first glance.

How do you know PageSpeed on nginx isn't using memcache?
> --
> You received this message because you are subscribed to the Google Groups
> "ngx-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ngx-pagespeed-di...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
> For more options, visit https://groups.google.com/d/optout.

shiz

unread,
Jun 30, 2015, 2:27:14 PM6/30/15
to ngx-pagesp...@googlegroups.com
I know it's not using it because the disk cache - /var/cache/mod_pagespeed - is being populated with small files and the admin panel shows no memcache activity. No LRU or shared memory either.
PageSpeed Graphs - apache.pdf
PageSpeed Graphs - nginx.pdf

Jeff Kaufman

unread,
Jun 30, 2015, 3:31:31 PM6/30/15
to ngx-pagesp...@googlegroups.com
Hmm. Something is wrong with that ngx_pagespeed stats page; it's also
showing no activity on the file cache, which makes no sense. I'll
need to bring up a test server and see.
>> > email to ngx-pagespeed-di...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/ngx-pagespeed-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "ngx-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ngx-pagespeed-di...@googlegroups.com.

shiz

unread,
Jun 30, 2015, 4:13:58 PM6/30/15
to ngx-pagesp...@googlegroups.com
Thank you  Jeff,  Please tell me if I can be of any help with tests.
>> > Visit this group at
>> > http://groups.google.com/group/ngx-pagespeed-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "ngx-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
Reply all
Reply to author
Forward
0 new messages