We are using Pagespeed on Nginx with Downstream Caching to Varnish for a Site. (URL: http://holi-gaudy.com )--Unfortunately it seems as if varnish is somehow deleting the expire settings of pagespeed in the setup.At least Pagespeed Insights tells us, that there are a lot of css/js/webp files without expiration date set.In addition the Files are missed by varnish and move always through pagespeed.Example File:Response Headers:
Accept-Ranges:bytes Age:0 Age:0 Connection:keep-alive Content-Encoding:gzip Content-Length:813 Content-Type:text/css Date:Wed, 26 Mar 2014 15:12:29 GMT Server:nginx Vary:Accept-Encoding Via:1.1 varnish Via:1.1 varnish X-Cache:MISS X-Page-Speed:1.7.30.4-3847 X-Varnish:1323764441 X-Varnish:1287915516The URL to the page: http://holi-gaudy.comPagespeed statistics & config are accessible: http://holi-gaudy.com/ngx_pagespeed_statistics?confignginx config: http://pastebin.com/tBxDfi13pagespeed include: http://pastebin.com/7PZ0YrYHvarnish config: http://pastebin.com/yuf01WEJWe are using the recommended varnish config from the pagespeed documentation.Would it be better to use the caching feature of nginx instead of varnish?Main problems are:- no expire date for a lot of the css/js files- varnish misses the files (tried with same browser)Any help would be very appreciated!
Thank you very much!
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.
I'm not really a varnish expert - but it seems to me that varnish will miss the files because of this in the varnish configuration ( vcl_recv ):
# Block 5a: Bypass the cache for .pagespeed. resource. PageSpeed has its own # cache for these, and these could bloat up the caching layer. if (req.url ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+") { # Skip the cache for .pagespeed. resource. PageSpeed has its own # cache for these, and these could bloat up the caching layer. return (pass); }
I haven't been able to figure out why your cache-control and expiry headers are dropped.Are you able to check if they are served properly when your request a .pagespeed. resource directly on the webserver?
Otto
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsub...@googlegroups.com.
As far as i understood the files are stored per User-Agent in Varnish after the initial pagespeed handshake for the next requests in the session.
If i deactivate varnish and serve the requests only through nginx the headers are set correctly.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
As far as i understood the files are stored per User-Agent in Varnish after the initial pagespeed handshake for the next requests in the session.Varnish will cache the html, but it looks like pagespeed resources are always fetched from the origin by design. The is served from the cache when I look - so that works as far as I can tell.
If i deactivate varnish and serve the requests only through nginx the headers are set correctly.If the headers are served ok from nginx, it looks like somehow they are changed when passing through Varnish right? There are also some duplicated headers, which I think is caused by PageSpeed fetching resources via Varnish. You might be able to avoid that by using MapOriginDomain (or LoadFromFile) in ngx_pagespeed [1]. Some urls respond with 3 "Accept-Ranges: bytes" headers, for example:I'm not sure why that is. Is the vcl you linked to your full configuration?
pagespeed MapOriginDomain localhost holi-gaudy.com;
pagespeed MapOriginDomain http://127.0.0.1:8080 http://holi-gaudy.com;
Otto
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsubscri...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/d/optout.
yes this works. But initially i thought the Hit Ratio would be higher... Server through nginx + ngx_pagespeed/memcache is still a lot slower than using varnish.
Is this the right usage of MapOriginDomain when varnish is running at :80 and using 127.0.0.1:8080 as backend?
pagespeed MapOriginDomain http://127.0.0.1:8080 http://holi-gaudy.com;
pagespeed MapOriginDomain http://127.0.0.1:8080 http://www.holi-gaudy.com;
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
Regarding Expires header, I am wondering if https://github.com/pagespeed/ngx_pagespeed/pull/555/files could have anything to do with this. This was intended to be applied for HTML only, but I don't know if it happened to somehow get rid of Expires (and other headers) for other resources as well. Could you take a look?
Sounds like it would be a good idea to monitor the cache hit rate even more closely when enabling caching of .pagespeed. resources, right?Regarding Expires header, I am wondering if https://github.com/pagespeed/ngx_pagespeed/pull/555/files could have anything to do with this. This was intended to be applied for HTML only, but I don't know if it happened to somehow get rid of Expires (and other headers) for other resources as well. Could you take a look?I was working with the assumption that ngx_pagespeed is serving the headers OK -- earlier in this thread:"If i deactivate varnish and serve the requests only through nginx the headers are set correctly."I also don't see ModifyCachingHeaders anywhere in the mentioned configurations.Nevertheless, I'll double check to see if this is working correctly for resources.
Regarding Expires header, I am wondering if https://github.com/pagespeed/ngx_pagespeed/pull/555/files could have anything to do with this. This was intended to be applied for HTML only, but I don't know if it happened to somehow get rid of Expires (and other headers) for other resources as well. Could you take a look?
I was working with the assumption that ngx_pagespeed is serving the headers OK -- earlier in this thread:"If i deactivate varnish and serve the requests only through nginx the headers are set correctly."I also don't see ModifyCachingHeaders anywhere in the mentioned configurations.Nevertheless, I'll double check to see if this is working correctly for resources.
ModifyCachingHeaders should be on by default right? However, if the test you mention above (deactivating varnish) worked, then I too have no clue as to what might be going on.One extreme way to test this might be to replace the varnish config with the default config (without the downstream-caching-related blocks), and see if this problem still persists. Otto, do you think that might be useful for Andreas to try?
A random query: What does the following block in your pagespeed config do?
# 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 "" ""; }
--
Anupama--
Anupama
Regarding Expires header, I am wondering if https://github.com/pagespeed/ngx_pagespeed/pull/555/files could have anything to do with this. This was intended to be applied for HTML only, but I don't know if it happened to somehow get rid of Expires (and other headers) for other resources as well. Could you take a look?Should i test with an earlier version of ngx_pagespeed? or what exactly to look at this link? (unfortunately my developer skills are limited :) )
I was working with the assumption that ngx_pagespeed is serving the headers OK -- earlier in this thread:"If i deactivate varnish and serve the requests only through nginx the headers are set correctly."I also don't see ModifyCachingHeaders anywhere in the mentioned configurations.Nevertheless, I'll double check to see if this is working correctly for resources.
ModifyCachingHeaders should be on by default right? However, if the test you mention above (deactivating varnish) worked, then I too have no clue as to what might be going on.One extreme way to test this might be to replace the varnish config with the default config (without the downstream-caching-related blocks), and see if this problem still persists. Otto, do you think that might be useful for Andreas to try?
As far as i understood ModifyCachingHeaders is enabled per default. As mentioned before if i disable varnish and use plain nginx the expire headers are set correctly.Should i test with a default varnish config? Or deactivate the 3 lines in the pagespeed config considering DownstreamCaching? Both?
As far as i understood ModifyCachingHeaders is enabled per default. As mentioned before if i disable varnish and use plain nginx the expire headers are set correctly.Should i test with a default varnish config? Or deactivate the 3 lines in the pagespeed config considering DownstreamCaching? Both?If it is possible to test in all modes, i.e. (a) with default varnish config and DownstreamCaching enabled, (b) with current config and with DownstreamCaching disabled in pagespeed end and (c) both a and b, it will help debug the situation better. I think (a) would be the most useful one
...
Anapuma: seems your suspicion was right -- adding this line to nginx.conf makes the cache headers disappear for .pagespeed. resources:
pagespeed DownstreamCachePurgeLocationPrefix http://localhost:80/;I'll have a look at how to fix this.Andreas - are your sure that direct requests on the origin return cacheable responses?It seems that with the basic varnish configuration, the Expiry/Cache-Control headers still are omitted.
Am Dienstag, 1. April 2014 19:11:59 UTC+2 schrieb Otto van der Schaaf:Anapuma: seems your suspicion was right -- adding this line to nginx.conf makes the cache headers disappear for .pagespeed. resources:
pagespeed DownstreamCachePurgeLocationPrefix http://localhost:80/;I'll have a look at how to fix this.Andreas - are your sure that direct requests on the origin return cacheable responses?It seems that with the basic varnish configuration, the Expiry/Cache-Control headers still are omitted.in the nginx only setup i commented the 3 lines regarding DownstreamCaching in nginx, cause i thought it won't work this way in any case.I am sorry to confuse you on this issue.This was the only configuration change i did in the nginx only setup.Should i reactivate it for testing?
in the nginx only setup i commented the 3 lines regarding DownstreamCaching in nginx, cause i thought it won't work this way in any case.I am sorry to confuse you on this issue.This was the only configuration change i did in the nginx only setup.Should i reactivate it for testing?Andreas, are you saying that if you retain the new varnish config (with downstream-caching specific stuff included) and use the pagespeed conf that does not use the 3 DownstreamCaching lines, you are able to get Expires and Cache-Control headers properly for your css files. If yes, this seems to tally well with what Otto just said "adding this line to nginx.conf makes the cache headers disappear for .pagespeed. resources: pagespeed DownstreamCachePurgeLocationPrefix http://localhost:80/;".
Otto
Otto
...To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsubscribe@googlegroups.
in the nginx only setup i commented the 3 lines regarding DownstreamCaching in nginx, cause i thought it won't work this way in any case.I am sorry to confuse you on this issue.This was the only configuration change i did in the nginx only setup.Should i reactivate it for testing?Andreas, are you saying that if you retain the new varnish config (with downstream-caching specific stuff included) and use the pagespeed conf that does not use the 3 DownstreamCaching lines, you are able to get Expires and Cache-Control headers properly for your css files. If yes, this seems to tally well with what Otto just said "adding this line to nginx.conf makes the cache headers disappear for .pagespeed. resources: pagespeed DownstreamCachePurgeLocationPrefix http://localhost:80/;".no, by "Nginx Only" Setup i mean a setup where Nginx is listening on the external IP and varnish is completely deactivated.So, should i test with "nginx only" setup and enable DownstreamCache in order to check if the headers aren't existing there?
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
I'm think I have a fix ready at https://github.com/pagespeed/ngx_pagespeed/compare/morlovich-trunk-tracking-upto-r3895...oschaaf-downstream-caching-headersIt yet needs to be reviewed - but do you want to try it out?If so, I can look into a patch that will apply cleanly to your version.
...
--
make[1]: Entering directory `/root/src/net/instaweb/automatic'/usr/bin/g++ -I/root/src -I/root/src/out/Release/obj/gen/protoc_out/instaweb -I/root/src/third_party/chromium/src -I/root/src/third_party/gflags/gen/arch/linux/x64/include -I/root/src/third_party/google-sparsehash/src -I/root/src/third_party/google-sparsehash/gen/arch/linux/x64/include -I/root/src/third_party/protobuf/src -I/root/src/third_party/re2/src -DSERF_HTTPS_FETCHING=0 -c static_rewriter_main.cc -o /root/src/net/instaweb/automatic/static_rewriter_main.oIn file included from /root/src/pagespeed/kernel/base/statistics.h:29:0, from /root/src/pagespeed/kernel/base/null_statistics.h:23, from /root/src/net/instaweb/util/public/null_statistics.h:20, from /root/src/net/instaweb/rewriter/public/rewrite_driver_factory.h:27, from /root/src/net/instaweb/automatic/public/static_rewriter.h:22, from static_rewriter_main.cc:21:/root/src/pagespeed/kernel/base/string_util.h:32:33: fatal error: base/stringprintf.h: No such file or directory # include "base/stringprintf.h" ^compilation terminated.make[1]: *** [/root/src/net/instaweb/automatic/static_rewriter_main.o] Error 1make[1]: Leaving directory `/root/src/net/instaweb/automatic'make: *** [all] Error 2
gclient config http://modpagespeed.googlecode.com/svn/trunk/src
gclient sync --force --jobs=1make AR.host="$PWD/build/wrappers/ar.sh" AR.target="$PWD/build/wrappers/ar.sh" BUILDTYPE=Release mod_pagespeed_test pagespeed_automatic_test cd net/instaweb/automatic/
make CXXFLAGS="-DSERF_HTTPS_FETCHING=0" BUILDTYPE=Release AR.host="$PWD/../../../build/wrappers/ar.sh" AR.target="$PWD/../../../build/wrappers/ar.sh" all
...
gclient sync --force --jobs=1 --revision=3895
Otto
--
In case it helps, here is the documentation that tells you how to build ngx_pagespeed synced to PSOL trunk: https://github.com/pagespeed/ngx_pagespeed/wiki/Building-trunk-tracking-ngx_pagespeed-with-PSOL-synced-to-trunk
ll ngx_pagespeed-release-1.7.30.4-betatotal 90532-rw-r--r-- 1 root root 92652779 Mar 13 14:00 1.7.30.4.tar.gz-rw-r--r-- 1 root root 8133 Mar 13 15:37 config-rw-r--r-- 1 root root 2881 Mar 13 15:37 cpp_feature-rw-r--r-- 1 root root 11342 Mar 13 15:37 LICENSEdrwxr-x--- 4 182960 5000 4096 Mar 12 20:55 psol-rw-r--r-- 1 root root 4833 Mar 13 15:37 README.mddrwxr-xr-x 2 root root 4096 Mar 13 15:37 scriptsdrwxr-xr-x 2 root root 4096 Mar 13 15:37 srcdrwxr-xr-x 2 root root 4096 Mar 13 15:37 testroot@web101:/usr/src/pagespeed/nginx-1.4.7/debian/modules# ll ngx_pagespeed-release-1.7.30.4-beta/psol/total 12drwxr-x--- 9 182960 5000 4096 Mar 12 20:00 include-rw-r----- 1 182960 5000 62 Mar 12 20:55 include_history.txtdrwxr-x--- 4 182960 5000 4096 Mar 12 20:55 lib
lltotal 78drwxr-xr-x 4 root root 1024 Apr 2 15:58 basedrwxr-xr-x 10 root root 1024 Apr 2 15:58 build-rw-r--r-- 1 root root 9353 Apr 2 15:54 DEPSdrwxr-xr-x 7 root root 1024 Apr 2 15:55 googleurldrwxr-xr-x 4 root root 1024 Apr 2 15:54 googleurl_noconvdrwxr-xr-x 8 root root 1024 Apr 2 15:54 install-rw-r--r-- 1 root root 57743 Apr 2 15:58 Makefiledrwxr-xr-x 3 root root 1024 Apr 2 15:54 netdrwxr-xr-x 3 root root 1024 Apr 2 15:58 outdrwxr-xr-x 3 root root 1024 Apr 2 15:58 pagespeeddrwxr-xr-x 8 root root 1024 Apr 2 15:58 testingdrwxr-xr-x 29 root root 1024 Apr 2 15:57 third_partydrwxr-xr-x 4 root root 1024 Apr 2 15:58 tools
gclient sync --force --jobs=1 --revision=3895
....
...
______ running '/usr/bin/python src/build/gyp_chromium -Dchromium_revision=161115' in '/root/mod_pagespeed'Updating projects from gyp files...Traceback (most recent call last): File "../build/version.py", line 25, in <module> execfile(os.path.join(chrome_src, 'chrome', 'tools', 'build', 'version.py'))IOError: [Errno 2] No such file or directory: '../third_party/chromium/src/chrome/tools/build/version.py'gyp: Call to 'python ../build/version.py -f ../net/instaweb/public/VERSION -t "@MAJOR@.@MINOR@.@BUILD@.@PATCH@"' returned exit status 1. while loading dependencies of /root/mod_pagespeed/src/build/all.gyp while trying to load /root/mod_pagespeed/src/build/all.gypError: Command /usr/bin/python src/build/gyp_chromium -Dchromium_revision=161115 returned non-zero exit status 1 in /root/mod_pagespeed
/usr/src/pagespeed/nginx-1.4.7/debian/modules/nginx-upstream-fair/ngx_http_upstream_fair_module.ccc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -Wno-unused-local-typedefs -Wno-error -I src/core -I src/event -I src/event/modules -I src/os/unix -I /root/mod_pagespeed/src -I /root/mod_pagespeed/src/third_party/chromium/src -I /root/mod_pagespeed/src/third_party/google-sparsehash/src -I /root/mod_pagespeed/src/third_party/google-sparsehash/gen/arch/linux/x64/include -I /root/mod_pagespeed/src/third_party/protobuf/src -I /root/mod_pagespeed/src/third_party/re2/src -I /root/mod_pagespeed/src/out/Debug/obj/gen -I /root/mod_pagespeed/src/out/Debug/obj/gen/protoc_out/instaweb -I /root/mod_pagespeed/src/third_party/apr/src/include -I /root/mod_pagespeed/src/third_party/aprutil/src/include -I /root/mod_pagespeed/src/third_party/apr/gen/arch/linux/x64/include -I /root/mod_pagespeed/src/third_party/aprutil/gen/arch/linux/x64/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/mail \ -o objs/addon/ngx_http_substitutions_filter_module/ngx_http_subs_filter_module.o \ /usr/src/pagespeed/nginx-1.4.7/debian/modules/ngx_http_substitutions_filter_module/ngx_http_subs_filter_module.ccc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -Wno-unused-local-typedefs -Wno-error -I src/core -I src/event -I src/event/modules -I src/os/unix -I /root/mod_pagespeed/src -I /root/mod_pagespeed/src/third_party/chromium/src -I /root/mod_pagespeed/src/third_party/google-sparsehash/src -I /root/mod_pagespeed/src/third_party/google-sparsehash/gen/arch/linux/x64/include -I /root/mod_pagespeed/src/third_party/protobuf/src -I /root/mod_pagespeed/src/third_party/re2/src -I /root/mod_pagespeed/src/out/Debug/obj/gen -I /root/mod_pagespeed/src/out/Debug/obj/gen/protoc_out/instaweb -I /root/mod_pagespeed/src/third_party/apr/src/include -I /root/mod_pagespeed/src/third_party/aprutil/src/include -I /root/mod_pagespeed/src/third_party/apr/gen/arch/linux/x64/include -I /root/mod_pagespeed/src/third_party/aprutil/gen/arch/linux/x64/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/mail \ -o objs/addon/src/log_message_handler.o \ /root/ngx_pagespeed/src/log_message_handler.cc/root/ngx_pagespeed/src/log_message_handler.cc:31:41: fatal error: net/instaweb/public/version.h: No such file or directory #include "net/instaweb/public/version.h"
find . | grep -i version.h./mod_pagespeed/src/out/Release/.deps/out/Release/obj.target/build/mod_pagespeed_version_header.stamp.d./mod_pagespeed/src/out/Release/.deps/out/Release/obj/gen/net/instaweb/public/version.h.d./mod_pagespeed/src/out/Release/obj.target/build/mod_pagespeed_version_header.stamp./mod_pagespeed/src/out/Release/obj/gen/net/instaweb/public/version.h./mod_pagespeed/src/build/mod_pagespeed_version_header.target.mk./mod_pagespeed/src/net/instaweb/public/version.h.in./mod_pagespeed/src/third_party/aprutil/src/include/apu_version.h./mod_pagespeed/src/third_party/apr/src/include/apr_version.h./mod_pagespeed/src/third_party/chromium/src/base/win/windows_version.h./mod_pagespeed/src/third_party/chromium/src/base/i18n/case_conversion.h./mod_pagespeed/src/third_party/chromium/src/base/version.h./mod_pagespeed/src/third_party/chromium/src/base/chromeos/chromeos_version.h./mod_pagespeed/src/third_party/icu/source/common/unicode/uversion.h./mod_pagespeed/src/third_party/libjpeg_turbo/src/jversion.h./mod_pagespeed/src/third_party/libjpeg_turbo/yasm/genversion.host.mk./mod_pagespeed/src/third_party/mod_spdy/src/mod_spdy/common/version.h.in
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsub...@googlegroups.com.
cd /usr/src/pagespeed/nginx-1.4.7/debian/build-full && MOD_PAGESPEED_DIR="/root/mod_pagespeed/src" ./configure \ --with-cc-opt="-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2" --with-ld-opt="-Wl,-z,relro" --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_addition_module \ --with-http_dav_module \ --with-http_geoip_module \ --with-http_gzip_static_module \ --with-http_image_filter_module \ --with-http_spdy_module \ --with-http_sub_module \ --with-http_xslt_module \ --with-mail \ --with-mail_ssl_module \ --add-module=/usr/src/pagespeed/nginx-1.4.7/debian/modules/nginx-auth-pam \ --add-module=/usr/src/pagespeed/nginx-1.4.7/debian/modules/nginx-dav-ext-module \ --add-module=/usr/src/pagespeed/nginx-1.4.7/debian/modules/nginx-echo \ --add-module=/usr/src/pagespeed/nginx-1.4.7/debian/modules/nginx-upstream-fair \ --add-module=/usr/src/pagespeed/nginx-1.4.7/debian/modules/ngx_http_substitutions_filter_module \ --add-module=/root/ngx_pagespeed \ >config.status.full
is it searching in the wrong directory?
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsubscri...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.