New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sendfile messages should not be cached #1050

Closed
GoogleCodeExporter opened this Issue Apr 6, 2015 · 26 comments

Comments

Projects
None yet
5 participants
@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Apr 6, 2015

From lmaroncelli:

<link rel="stylesheet" type="text/css" 
href="www.info-alberghi.com/css/style.css">

is replaced with:

<style></style>

on:

http://www.info-alberghi.com/

which is on version: 1.9.32.2-4321



Here's the context for the missing <link>:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2007570-1']);
_gaq.push(['_setDomainName', 'info-alberghi.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; 
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 
'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; 
s.parentNode.insertBefore(ga, s);
})();

</script>
<style></style>
<script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

Original issue reported on code.google.com by sligocki@google.com on 24 Feb 2015 at 4:45

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

As Jeff noted, this is producing very strange results:

?PageSpeed=off
  <link rel="stylesheet" type="text/css" href="http://www.info-alberghi.com/css/style.css">

?PageSpeed=on
  <style></style>

?PageSpeedFilters=+debug (First load)
  <link rel="stylesheet" type="text/css" href="http://www.info-alberghi.com/css/style.css"><!--deadline_exceeded for filter CacheExtender--><!--deadline_exceeded--><!--deadline_exceeded for filter CssFilter-->

?PageSpeedFilters=+debug (Second load)
  <style></style><!--CSS rewrite failed: Cannot improve http://www.info-alberghi.com/css/style.css-->


Original comment by sligocki@google.com on 24 Feb 2015 at 6:02

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

?PageSpeedFilters=debug,inline_css
  <link rel="stylesheet" type="text/css" href="http://www.info-alberghi.com/css/style.css"><!--CSS not inlined since it's bigger than 2048 bytes-->

?PageSpeedFilters=debug,rewrite_css
  <link rel="stylesheet" type="text/css" href="http://www.info-alberghi.com/css/A.style.css.pagespeed.cf.aDqQRUaJ0h.css">

?PageSpeedFilters=debug,extend_cache_css
  <link rel="stylesheet" type="text/css" href="http://www.info-alberghi.com/css/style.css">

Note resource has 1 year cache lifetime.

Original comment by sligocki@google.com on 24 Feb 2015 at 6:30

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

We've received another report with the same symptoms:

https://groups.google.com/d/msgid/mod-pagespeed-discuss/6c12a9df-72ec-4897-bed1-
9d4d101e14bb%40googlegroups.com?utm_medium=email&utm_source=footer

Original was: 
https://groups.google.com/d/msgid/mod-pagespeed-discuss/d83e4922-2756-482d-87c1-
35c28c55d4d3%40googlegroups.com?utm_medium=email&utm_source=footer

Original comment by sligocki@google.com on 10 Mar 2015 at 8:33

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

The new report is for <script> instead of <style> so this applies to both types 
of resources. We suspect it could be an issue with IPRO recording, but have not 
been able to reproduce yet.

Original comment by sligocki@google.com on 10 Mar 2015 at 8:35

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Both users report that this is still an issue with IPRO disabled.

Original comment by sligocki@google.com on 11 Mar 2015 at 2:50

@GoogleCodeExporter

This comment has been minimized.

Copy link

GoogleCodeExporter commented Apr 6, 2015

Actually, after following up further it seems that disabling IPRO did fix this 
problem for both users. Trying to get them to re-enable IPRO in a limited 
setting to let us debug.

Original comment by sligocki@google.com on 13 Mar 2015 at 2:36

@sligocki sligocki self-assigned this Apr 9, 2015

@crowell crowell added this to the 1.9.32.4 milestone Apr 13, 2015

@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented Apr 20, 2015

From lmaroncelli@gmail.com:

[Tue Apr 14 10:11:38 2015] [error] [mod_pagespeed 1.9.32.3-4448 @3747] [0414/101138:ERROR:in_place_resource_recorder.cc(225)] Empty resource in IPRO for URL http://www.info-alberghi.com/js/jquery.countdown.js Response headers: HTTP/1.0 200 (null)\r\nX-Accel-Version: 0.01\r\nX-Accel-Redirect: /internal-nginx-static-location/js/jquery.countdown.js\r\nCache-Control: public, max-age=31536000\r\nExpires: Wed, 13 Apr 2016 08:11:38 GMT\r\nVary: Accept-Encoding\r\nContent-Encoding: gzip\r\nX-Powered-By: PleskLin\r\nContent-Length: 20\r\nConnection: close\r\nContent-Type: text/javascript\r\nDate: Tue, 14 Apr 2015 08:11:38 GMT\r\n\r\n Request headers: GET HTTP/1.0\r\nHost:www.info-alberghi.com\r\nX-Real-IP: 151.47.123.28\r\nX-Forwarded-For: 151.47.123.28\r\nX-Accel-Internal: /internal-nginx-static-location\r\nConnection: close\r\nAccept: /\r\nUser-Agent: Mozilla/5.0 (Linux; Android 4.4.2; it-it; SAMSUNG GT-I9505 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrom
e/28.0.1500.94 Mobile Safari/537.36\r\nReferer: http://www.info-alberghi.com/mail_scheda_inviata_new.php\r\nAccept-Encoding: gzip,deflate,sdch

@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented Apr 20, 2015

From @jeffkaufman:

Thanks for sending this! It looks like the key thing in this error is:

X-Accel-Redirect: /internal-nginx-static-location/js/jquery.countdown.js

Your site is set up like this, right?

[user] -> [nginx] -> [apache+mod_pagespeed]

What's happening is that apache is issuing a response like this:

HTTP/1.0 200 (null)
...
X-Accel-Redirect: /internal-nginx-static-location/js/jquery.countdown.js
Cache-Control: public, max-age=31536000
...

[empty response body]

Then nginx sees the X-Accel-Redirect header, and reads the relevant file off of disk to send out as the response body.

We can think of PageSpeed as sitting between nginx and apache, which means it sees this response before the response body is filled in. The problem is, PageSpeed doesn't know it's seeing an incomplete response, so it saves a copy of the response body (empty) as it goes by and then later when it sees references to that file in the html it inlines it as an empty resource.

Thanks for helping us debug this! For your site, and any other sites having this issue with 1.9.32.3 the best fix is to turn off IPRO:

ModPagespeedInPlaceResourceOptimization off

In our next release we'll make sure to handle this case. I think what we need to do is:

  • Recognize that X-Accel-Redirect means a response is incomplete, and don't cache it.
  • Look for other headers that mean this and blacklist them as well.
  • In case there are any other headers used for this, don't cache any responses that have an empty body.

Relevant doc:

@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented Apr 20, 2015

A fix is in progress.

@sachinjsk

This comment has been minimized.

Copy link

sachinjsk commented Apr 20, 2015

Hi guys,

I'm running into the same issue.

I've setup enjoy-swimming.com with pretty much all the default settings. Rewrite level is set to CoreFilters. With Pagespeed on

<link rel="stylesheet" href="http://www.enjoy-swimming.com/support-files/master.css" type="text/css" />

was getting replaced with:

<style></style>

I could see that there are some css errors in that page, so I tried disabling inline_css filter, but that didn't fix it. It was generating a pagespeed specific cache file, but that was empty.

After reading comments here I tried turning off ModPagespeedInPlaceResourceOptimization, but that didn't help either.

What I find odd is that the page loads fine in Chrome but not in Firefox or Safari. You can see it in action by visiting - http://www.enjoy-swimming.com/?ModPagespeed=on

Please note that the rewritten master.css file looks good in chrome, but is empty in Safari/Firefox.

Domain: http://www.enjoy-swimming.com
Pagespeed version: 1.9.32.3-stable

Thanks for any help.

Sachin

@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented Apr 20, 2015

Hi @sachinjsk,

Can you try flushing the mod_pagespeed cache and see if that fixes things? You can do this by simply changing the filename of master.css to something like master.css?1 or by following these instructions: https://developers.google.com/speed/pagespeed/module/system#purge_cache (Leave ModPagespeedInPlaceResourceOptimization off as well)

This bug is polluting the mod_pagespeed cache and we have separate cache values for different sets of browsers. It looks like your cache has broken values for Firefox, but good values for Chrome, flushing should harmonize them.

@sachinjsk

This comment has been minimized.

Copy link

sachinjsk commented Apr 20, 2015

Hi @sligocki,

I purged the entire cache via Pagespeed admin page. Still broken in Firefox/Safari.

ModPagespeedInPlaceResourceOptimization is turned off.

@sachinjsk

This comment has been minimized.

Copy link

sachinjsk commented Apr 20, 2015

Please let me know if there's anything else I can help with to narrow down this bug.

@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Apr 21, 2015

Checking enjoyswimming.com, in FF I see:

http://www.enjoy-swimming.com/support-files/A.master.css.pagespeed.cf.7KqI9_oL9h.css

which is empty, while in Chrome I see:

http://www.enjoy-swimming.com/support-files/A.master.css.pagespeed.cf.i2p-4h4bmP.css

which consists of a single @import:

@import url(rwd-v2.css)

Loading http://www.enjoy-swimming.com/support-files/rwd-v2.css , that's not empty and has lots of css directives.

@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Apr 21, 2015

@sachinjsk Could you post your Apache config, or send it to jefftk@google.com ?

Is there anything in your Apache error log marked "error" or "warn"?

@sachinjsk

This comment has been minimized.

Copy link

sachinjsk commented Apr 21, 2015

@jeffkaufman I'm trying to setup a machine with simpler out of the box apache config. Will send you the config as soon as I have them ready.

@sachinjsk

This comment has been minimized.

Copy link

sachinjsk commented Apr 21, 2015

@jeffkaufman I've setup a machine with bare minimum apache config and its still broken in Safari/Firefox. I've sent you an email with the config details. There is nothing in apache error log.

Domain: http://www.enjoy-swimming.sbi2b.sitesell.com

The only change I have in pagespeed.conf:
ModPagespeedDisableFilters inline_css

@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Apr 22, 2015

I get the same missing-css issue testing this at http://www.jefftk.com/es-include-css/index

@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Apr 22, 2015

@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Apr 22, 2015

To get the failure:

  1. Pick a unique set of irrelevant PageSpeed query options to functionally clear the metadata cache. So ?PageSpeedFilters=+[something_silly].
  2. Open that URL in Chrome or FF, it should work, green screen.
  3. Open that URL in the other one, it shouldn't work, red screen.

On the passing side +debug gives me:

<style>@import url(support-files/rwd-v2.css) ;</style><!--Flattening failed:
A media query is too complex in http://www.jefftk.com/simple-include-css
/support-files/rwd-v2.css AND Cannot rewrite http://cfd.enjoy-swimming.
com/image-files-layout/rwd-header.png as it is on an unauthorized domain-->

On the failing side:

<style></style><!--Flattening failed: A media query is too complex in
http://www.jefftk.com/simple-include-css/support-files/rwd-v2.css-->
@jeffkaufman

This comment has been minimized.

Copy link
Contributor

jeffkaufman commented Apr 22, 2015

Even simpler test case: http://www.jefftk.com/simpler-include-css/

$ cat index.html 
<style>body {background: red}</style>
<link rel=stylesheet href="a.css" type="text/css"/>

$ cat a.css 
@import url(b.css) ;

$ cat b.css 
body {background: green}

@media screen and (min-width: 240px) {
  body {background: blue}
}
@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented Apr 22, 2015

This looks like a different issue. Created a new Issue #1068, to follow this.

@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented May 1, 2015

We think this will be fixed by commit 8f93d5c which disallows us from caching empty input resources.

@sligocki sligocki closed this May 1, 2015

@crowell

This comment has been minimized.

Copy link
Contributor

crowell commented May 13, 2015

reopening for follow-up cl to flush cache on upgrade.

@crowell crowell reopened this May 13, 2015

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 13, 2015

Do not rewrite nor cache empty resources.
backport @sligocki fix to bug #1050
While there is nothing technically wrong with caching and rewriting empty resources, there's not much value and we have run into situations where we unexpectedly produce empty resources.

Fixes issue 1050.

crowell added a commit that referenced this issue May 14, 2015

crowell added a commit that referenced this issue May 14, 2015

@sligocki

This comment has been minimized.

Copy link
Contributor

sligocki commented May 15, 2015

Cache flushed with 6c78f97 . Now this bug can be closed.

@sligocki sligocki closed this May 15, 2015

@crowell

This comment has been minimized.

Copy link
Contributor

crowell commented May 15, 2015

will backport 6c78f97 to branch 32

@jeffkaufman jeffkaufman changed the title CSS removed from site Empty resources should not be cached Jul 27, 2015

@jeffkaufman jeffkaufman changed the title Empty resources should not be cached Sendfile messages should not be cached, Jul 27, 2015

@jeffkaufman jeffkaufman changed the title Sendfile messages should not be cached, Sendfile messages should not be cached Jul 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment