Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Vanish and ngx_pagespeed conflict #177

Closed
DahmaniAdame opened this issue Feb 24, 2013 · 11 comments
Closed

Vanish and ngx_pagespeed conflict #177

DahmaniAdame opened this issue Feb 24, 2013 · 11 comments

Comments

@DahmaniAdame
Copy link

Environment : Ubuntu 12.10
Nginx : 1.2.7
Varnish : 3.0.2

ngx_pagespeed is up and running. Every thing seems to be working properly, except for rewrite_css and rewrite_javascript. All CSS and JS files are kept as they are.

When I use Varnish with ngx_pagespeed, some filters stop working, like css and js combine.

Once I turn off Varnish, every gets back to normal.

Is there a conflict with Varnish and ngx_pagespeed?
How can I get Varnish to work with ngx_pagespeed?
How can I get rewrites to work properly?

If you need any log or file to investigate more, just ask :)

@vidluther
Copy link

Regarding the varnish and pagespeed not working, it's not that they're
incompatible, but that Varnish caches the first request, and serves that,
so you never see the rewritten files in the request.

In terms of rewrites not working properly, what do you mean? What were you
expecting? What did you see?

On Sun, Feb 24, 2013 at 1:53 PM, adamedoe notifications@github.com wrote:

Environment : Ubuntu 12.10
Nginx : 1.2.7
Varnish : 3.0.2

ngx_pagespeed is up and running. Every thing seems to be working properly,
except for rewrite_css and rewrite_javascript. All CSS and JS files are
kept as they are.

When I use Varnish with ngx_pagespeed, some filters stop working, like css
and js combine.

Once I turn off Varnish, every gets back to normal.

Is there a conflict with Varnish and ngx_pagespeed?
How can I get Varnish to work with ngx_pagespeed?
How can I get rewrites to work properly?

If you need any log or file to investigate more, just ask :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/177.

Vid Luther
CEO and Founder
ZippyKid
Managed Wordpress Hosting
http://zippykid.com/
210-789-0369

@jeffkaufman
Copy link
Contributor

Could you paste the headers you're serving your html with when varnish is off? So:

curl -s -D- -o/dev/null http://example.com

ngx_pagespeed should be serving the html with Cache-Control: max-age=0, no-cache which I would expect Varnish to respect. (Which means that html won't be cached by Varnish, but resources will.)

@DahmaniAdame
Copy link
Author

@vidluther when I was checking css and js, the content wasn't minified, so I assume something's wrong with rewrites. After a couple of refresh, css and js files combined nicely and got minified.

@jeffkaufman here's the output of the code line :

HTTP/1.1 200 OK
Server: nginx/1.2.7
Date: Mon, 25 Feb 2013 18:22:47 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.4.6-1ubuntu1.1
Set-Cookie: frontend=s2105hajm07pl45nq7h9b4ro55; expires=Mon, 25-Feb-2013 19:22:47 GMT; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Cache-Control: max-age=0, no-cache
X-Page-Speed: 1.1.0.0-2338

Is it possible to make Varnish cache processed resources?

Thanks!

@jeffkaufman
Copy link
Contributor

when I was checking css and js, the content wasn't minified

When pagespeed runs it replaces resource links in your html with ones to minified resources. So <img src="foo.jpg"> becomes <img src="foo.jpg.pagespeed.ic.Va9zyutH31.jpg">. So when you say it wasn't minified, do you mean it wasn't minified as linked to in the html or that when loading the resource under it's original name it was left alone?

output of the code line:

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Cache-Control: max-age=0, no-cache

The duplicate cache-control headers aren't ideal (ngx_pagespeed is setting the final one, elsewhere in your config you're setting the first cache-control and the pragma), but shouldn't be causing this problem.

@DahmaniAdame
Copy link
Author

So when you say it wasn't minified, do you mean it wasn't minified as linked to in the html or that when loading the resource under it's original name it was left alone?

I was talking about the file's content. But it's working now :) It needed a couple of uses / refresh so that pagespeed compile it.

The duplicate cache-control headers aren't ideal (ngx_pagespeed is setting the final one, elsewhere in your config you're setting the first cache-control and the pragma), but shouldn't be causing this problem.

I'm aware of the double Control-Cache header. As they don't conflict, it's not a problem for now.

Back to our issue.

Is it possible to put pagespeed in front of Vanish? This will allow pagespeed to process the content AND to varnish to cache the result! Right?

@vidluther
Copy link

Sure, just have nginx call the pagespeed vhost, in other words, put nginx
on the public ip, and varnish on the private.

On Mon, Feb 25, 2013 at 4:29 PM, adamedoe notifications@github.com wrote:

Is it possible to put pagespeed in front of Vanish? This will allow
pagespeed to process the content AND to varnish to cache the result! Right?

@DahmaniAdame
Copy link
Author

@vidluther how can I set it up? knowing that pagespeed needs many calls to fully render the page...

@jeffkaufman
Copy link
Contributor

Are you still having trouble with this?

@DahmaniAdame
Copy link
Author

Yes, I still do.

I can't figure out how to make Varnish cache only fully processed pages, OR, making it recheck the page and cache changes if applied...

@jeffkaufman
Copy link
Contributor

Varnish cache only fully processed pages, OR, making it recheck the page and cache changes if applied...

Unfortunately pagespeed was designed around the idea that the html it generates wouldn't be cached. Everything else can be longcached, but the html needs to be uncacheable. Here's an explanation I sent to ngx-pagespeed-discuss the other day: https://groups.google.com/d/msg/ngx-pagespeed-discuss/vzSq8XQPGmM/-h9L6bS2OoMJ

@DahmaniAdame
Copy link
Author

Makes sense.
Thanks for the explanation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants