Search code examples
amazon-elbmod-pagespeed

mod_pagespeed behind elastic load balancer


mod_pagespeed rewrites my css links from

link href="/css/file.css" rel="stylesheet"

to something like:

link href="http://example.com/css/file.css.pagespeed.ce.97987.css" rel="stylesheet"

The problem is that if file.css.pagespeed.ce.97987.css hasn't been created in the pagespeed cache by one of the servers behind the load balancer it may not be found.

It does the same thing with .js files and images

Is it possible to access these files on the local server rather than asking the load balancer to serve them?

EDIT:

This has been solved by:

ModPagespeedEnableFilters trim_urls

Which rewrites to

link href="/css/file.css.pagespeed.ce.97987.css" rel="stylesheet"

EDIT 2:

This rewrote the hrefs in the a links and stripped out the base url from those, which isn't good since I want them to redirect to the load balancer


Solution

  • if you don't have any directory rewrite rules in your .htaccess you can create a stickiness policy. this means that the elb holds a tcp connection to one instance of the scaling group for a defined time. further you have to add the stickiness policy to the listeners.