apache / incubator-pagespeed-mod

Apache module for rewriting web pages to reduce latency and bandwidth.
http://modpagespeed.com
Apache License 2.0
696 stars 158 forks source link

Not rewriting any static assets #954

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I've searched high and low for around a week now attempting to debug this 
issue, so i'm only posting here as a last resort, as i now think this could be 
a bug:

I've enabled pagespeed on our website, https://hostpresto.com - by default this 
will 301 to https, however in my testing i have been using http:// as well to 
rule that out.

Pagespeed is enabled and the header is being added in the main text/html 
response (as you can see the beacons are added and it's stripped of 
whitespace), however, there is no rewriting of any static assets at all - even 
simple javascript.  I've checked my cache headers and everything else i can 
think of.  The log output shows as follows, which i believe where the issue is 
coming from, as the static assets don't appear to be cachable, but i cannot 
find a reason for this (note this is taken from the logs during non https 
testing):

---------------

[Wed Jul 02 23:55:46.290493 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/font-awesome/css/font-awesome.min.css: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.291124 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/font-awesome/css/font-awesome.min.css: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.291687 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/font-awesome/css/font-awesome.min.css: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.295866 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache key=http://hostpresto.com/assets/css/main.css: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.296486 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache key=http://hostpresto.com/assets/css/main.css: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.296966 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache key=http://hostpresto.com/assets/css/main.css: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.300948 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/jquery/jquery.min.js: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.301739 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/jquery/jquery.min.js: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.306113 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/bootstrap/dist/js/bootstrap.js: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.306893 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/vendor/bootstrap/dist/js/bootstrap.js: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.310319 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/js/jquery-scrolltofixed.js: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.310913 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/js/jquery-scrolltofixed.js: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.314869 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/js/responsive-nav.js: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.315374 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/js/responsive-nav.js: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.318399 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache key=http://hostpresto.com/assets/js/main.js: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.318910 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache key=http://hostpresto.com/assets/js/main.js: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.324474 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/favicon.ico: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.329054 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon.png: remembering 
not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.335384 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-57x57.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.338872 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-72x72.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.343956 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-76x76.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.349441 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-114x114.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.354897 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-120x120.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.360226 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-144x144.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.365992 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/icons/apple-touch-icon-152x152.png: 
remembering not-cacheable status for 299 seconds.
[Wed Jul 02 23:55:46.370917 2014] [pagespeed:info] [pid 14045] [mod_pagespeed 
1.7.30.5-3847 @14045] HTTPCache 
key=http://hostpresto.com/assets/img/logo-purple.png: remembering not-cacheable 
status for 299 seconds.

---------------

responsive-nav.js is a good test subject as it's unminified already and is a 
relatively simple and small js file:

Response headers for responsive-nav.js:

Accept-Ranges   bytes
Cache-Control   public, max-age=600
Connection  close
Content-Length  15517
Content-Type    application/javascript
Date    Wed, 02 Jul 2014 22:55:46 GMT
Last-Modified   Sun, 29 Jun 2014 17:42:21 GMT
Server  Apache

--------------

My pagespeed config:

ModPagespeed on
ModPagespeedFetchHttps enable
#ModPagespeedLoadFromFile http://hostpresto.com/assets, 
/home/hostpres/hostpresto/public/assets/  #tested this solution as well

ModPagespeedDomain *.addthis.com
ModPagespeedDomain google-analytics.com
ModPagespeedDomain *.zopim.com
ModPagespeedDomain *.googleapis.com

AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html

ModPagespeedFileCachePath            "/var/mod_pagespeed/cache/"

ModPagespeedRewriteLevel AllFilters

--------------

This site does does use mod_rewrite as it's a front controller design (i've 
read there are some issues with mod_Rewrite and pagespeed, so i don't know if 
this is the cause? However I have other sites on the same server using similar 
rewrite rules and they appear to be rewriting static assets ok. (Standard Zend 
Framework 2 front controller rewrite):

# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

--------------
What version of the product are you using (please check X-Mod-Pagespeed
header)?
1.7.30.5-3847

On what operating system?
CentOS 6

Which version of Apache?
2.4

Which MPM?
Event

URL of broken page:
https://hostpresto.com

Thanks for your time,

Elliot

Original issue reported on code.google.com by elli...@gmail.com on 3 Jul 2014 at 6:12

GoogleCodeExporter commented 9 years ago
mod_pagespeed doesn't follow redirects when fetching resources: 
https://code.google.com/p/modpagespeed/issues/detail?id=262

It looks like your http resources redirect to https versions.  If you load 
http://hostpresto.com and it links to everything via http, then resource 
rewriting is going to fail.

Original comment by jefftk@google.com on 4 Aug 2014 at 5:52

GoogleCodeExporter commented 9 years ago
Hi,

Thank you for your reply.  We use relative URLs for all resources - the log 
excerpt i pasted above was when i was testing in http, there were no https 
redirections in place.

Thanks,

Elliot

Original comment by elli...@gmail.com on 4 Aug 2014 at 6:00

GoogleCodeExporter commented 9 years ago
I think your LoadFromFile directive (commented out) might have a syntax error.  
The arguments are space-separated, not comma-separated, so the comma was 
interpreted as part of the URL prefix for matching, and that won't work.

If you have to stick with fetching those resources via http(s), you might need 
a ModPagespeedMapOriginDomain command to fetch from localhost or something.  
E.g.
   ModPagespeedMapOriginDomain localhost http*://*hostpresto.com

Original comment by jmara...@google.com on 9 Sep 2014 at 9:13

GoogleCodeExporter commented 9 years ago

Original comment by jmara...@google.com on 9 Sep 2014 at 9:13