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

Broken CSS and JS #1016

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Enable mod_pagespeed

What is the expected output? What do you see instead?
The page breaks. CSS is missing.
[Warning] Invalid CSS property declaration at: * (explore, line 12)
[Error] SyntaxError: Unexpected token '<'
    (anonym funksjon) (404, line 1)
[Error] ReferenceError: Can't find variable: mod_pagespeed_zDPdHCVuFD
    global code (explore, line 17)
[Error] ReferenceError: Can't find variable: mod_pagespeed_iQpYc3y0WS
    global code (explore, line 19)
[Error] ReferenceError: Can't find variable: mod_pagespeed_CEsjKphoff
    global code (explore, line 20)
[Error] ReferenceError: Can't find variable: mod_pagespeed_BsJQbncASZ
    global code (explore, line 21)

Disabling filters rewrite_javascript, and rewrite_images seems to fix it.

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

On what operating system?
Ubuntu 12.04 3.13.0-34-generic 

Which version of Apache?
Apache/2.4.10 (Ubuntu)

Which MPM?

URL of broken page:
http://cloudaud.io

Original issue reported on code.google.com by tho...@ndt-lan.no on 9 Nov 2014 at 9:50

GoogleCodeExporter commented 9 years ago
Looking at your site I see that your server is not serving the ".pagespeed." 
resources. For example:

Request URL: http://cloudaud.io/css/A.reset.css.pagespeed.cf.cY4p0TFV0A.css
Status Code: 301 Moved Permanently
Location: http://cloudaud.io/404

From: 
http://cloudaud.io/featured?ModPagespeed=on&ModPagespeedFilters=rewrite_css or 
http://cloudaud.io/featured?ModPagespeed=on&ModPagespeedFilters=rewrite_images

Are you using mod_rewrite? Rewrite rules can often conflict with ".pagespeed." 
resources. Or do you know of any other reason that your server would be serving 
404 for these ".pagespeed." resources?

Original comment by sligocki@google.com on 10 Nov 2014 at 3:18

GoogleCodeExporter commented 9 years ago
Hi, and thanks for your reply.
I had to disable mod_pagespeed for the site because if the issues.

I have now setup a virtual host that points to the exact same directory, but 
with mod_pagespeed enabled.

With mod_pagespeed:
http://dev.cloudaud.io/explore

Without mod_pagespeed:
http://cloudaud.io/explore

I have also reinstalled the latest version of mod_pagespeed, and reset the 
configuration file.
I also have a varnish front end, but I have tested with and without, and the 
issue still persists.

Here is my .htaccess:

AddType application/x-httpd-php .xml
AddType application/x-httpd-php .txt

RewriteEngine on
RewriteRule ^dev/([0-9a-zA-Z-]+) /$1 [NC,L,R=301]
RewriteRule ^dev / [NC,L,R=301]
RewriteRule ^profile/([0-9a-zA-Z-]+) /index.php?p=profile&user=$1 [NC,L]
RewriteRule ^404 /index.php?p=404 [NC,L]
RewriteRule ^reset/([0-9a-zA-Z-]+) /index.php?p=reset&key=$1 [NC,L]
RewriteRule ^passwordreset index.php?p=passwordreset [NC,L]
RewriteRule ^home/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^home /index.php?p=home [NC,L]
RewriteRule ^explore/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^explore /index.php?p=explore [NC,L]
RewriteRule ^featured/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^featured /index.php?p=featured [NC,L]
RewriteRule ^login/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^login /index.php?p=login [NC,L]
RewriteRule ^register/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^register /index.php?p=register [NC,L]
RewriteRule ^logout/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^logout /index.php?p=logout [NC,L]
RewriteRule ^upload/([0-9a-zA-Z-]+) /404 [NC,L,R=301]
RewriteRule ^upload /index.php?p=upload [NC,L]
RewriteRule ^track/([0-9a-zA-Z-]+)/([0-9a-zA-Z-]+) 
/index.php?p=track&id=$1&secret=$2 [NC,L]
RewriteRule ^track/([0-9a-zA-Z-]+) /index.php?p=track&id=$1 [NC,L]
RewriteRule ^track /index.php?p=track&id=0 [NC,L]
RewriteRule ^trackA/([0-9a-zA-Z-]+) /index.php?p=trackA&id=$1 [NC,L]
RewriteRule ^cleanup /404 [L]
RewriteRule ^process.php /404 [L,R=301]
RewriteRule ^queue.log /404 [L,R=301]
RewriteRule ^logview /404 [L,R=301]

# Stream security 
RewriteCond %{HTTP_REFERER} !cloudaud.io
RewriteRule ^stream/([0-9a-zA-Z-]+) /404 [NC,L,R=301]

#catch-all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /404 [L,R=301]

Original comment by tho...@ndt-lan.no on 17 Nov 2014 at 11:11

GoogleCodeExporter commented 9 years ago
These are the problem:

#catch-all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /404 [L,R=301]

These rules are causing all the rewritten resources to be forwarded to /404 
because they do not exist on your filesystem.

Try adding in:

RewriteCond %{REQUEST_URI} !^/mod_pagespeed_

So it would be:

#catch-all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/mod_pagespeed_
RewriteRule ^ /404 [L,R=301]

Original comment by sligocki@google.com on 17 Nov 2014 at 11:55

GoogleCodeExporter commented 9 years ago
Oops also add

RewriteCond %{REQUEST_URI} ![.]pagespeed[.]

So it would be:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ![.]pagespeed[.]
RewriteCond %{REQUEST_URI} !^/mod_pagespeed_
RewriteRule ^ /404 [L,R=301]

Original comment by sligocki@google.com on 17 Nov 2014 at 11:57

GoogleCodeExporter commented 9 years ago
Thanks that solved the problem, and I have now re-enabled it for the main vhost.
Sorry for the false bug report, my bad.

But it seems like the "lazyload_images" filter still is broken. If I enable 
that filter, the site loads fine, but all pictures outside of the current 
viewport (and some inside it!) won't load at all, even when scrolling to them.

What could cause this?

Original comment by thomas.a...@gmail.com on 18 Nov 2014 at 2:31

GoogleCodeExporter commented 9 years ago
This is actually a common problem, so I will add a note to the FAQ.

Let's open a new bug for that new issue.

Original comment by sligocki@google.com on 18 Nov 2014 at 4:29

GoogleCodeExporter commented 9 years ago

Original comment by sligocki@google.com on 18 Nov 2014 at 4:31

GoogleCodeExporter commented 9 years ago
Aha, I see that this is probably related, so I will add the solution here as 
well:

From 
http://dev.cloudaud.io/explore?ModPagespeed=on&ModPagespeedFilters=lazyload_imag
es

<img id="track_6" class="wave unselectable" height="70" width="900" 
pagespeed_lazy_src="/index.php?p=wave&id=151" alt="waveform" 
pagespeed_url_hash="2904038479" src="/pagespeed_static/1.JiBnMqyl6S.gif" 
onload="pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);" 
pagespeed_lazy_replaced_functions="1">

So we must whitelist /pagespeed_static as well. So perhaps we should just 
whitelist all URLs with pagespeed in them:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !pagespeed
RewriteRule ^ /404 [L,R=301]

Does that fix the problem for you?

Original comment by sligocki@google.com on 18 Nov 2014 at 4:40

GoogleCodeExporter commented 9 years ago
Added to the FAQ: 
https://developers.google.com/speed/pagespeed/module/faq#mod_rewrite

Original comment by sligocki@google.com on 20 Nov 2014 at 6:23

Ranjit-Kr commented 6 years ago

Recently page speed has been implemented on our website- there is a functionality for reset password on my website that triggers otp to mobile. After getting otp page redirects to reset password page. Afetr entering otp and clicking on continue i am getting the following error :

clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 Uncaught TypeError: Illegal invocation at K (clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8) at a.fn.init.text (clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8) at Object.success (resetpassword.js.pagespeed.jm.b8U5GDu-kU.js:1) at i (clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8) at Object.fireWith [as resolveWith] (clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8) at z (clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8) at XMLHttpRequest. (clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8) K @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 text @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 success @ resetpassword.js.pagespeed.jm.b8U5GDu-kU.js:1 i @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 fireWith @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 z @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 (anonymous) @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 XMLHttpRequest.send (async) send @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 ajax @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 submitResetPassRequest @ resetpassword.js.pagespeed.jm.b8U5GDu-kU.js:1 (anonymous) @ resetpassword.js.pagespeed.jm.b8U5GDu-kU.js:1 dispatch @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8 r.handle @ clientlibs.js.pagespeed.jm.P4bq0aKKBT.js:8

oschaaf commented 6 years ago

@Ranjit-Kr You could try disabling the rewrite_javascript to see if that resolves the issue. https://www.modpagespeed.com/doc/config_filters

Note that this issue is old and has been closed a long time ago -- I think it's best to move further discussion to https://groups.google.com/d/topic/mod-pagespeed-discuss