In which part of the code in mod_pagespeed, the css file is opened and the references are rewritten?

18 views
Skip to first unread message

anir...@webscalenetworks.com

unread,
Jun 21, 2016, 1:02:26 PM6/21/16
to mod-pagespeed-discuss
Suppose I have following contents in one of the css files:


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

body {

    background: url("/wp-content/uploads/2015/10/home.jpg") no-repeat scroll center top;

    height: 100%

}

@import url('morestyles.css')

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


The relative reference like morestyles.css is rewritten in a correct way, however, the absolute reference (starting with "/") is written in an incorrect way. 


So I want to know exactly where in the code the css file is opened and references are rewritten so that I could go there and make necessary changes for my application. 

Jeffrey Crowell

unread,
Jun 21, 2016, 2:28:59 PM6/21/16
to mod-pagespeed-discuss

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/5d0b1856-68d0-471d-854c-707b6ccd59f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

anir...@webscalenetworks.com

unread,
Jun 21, 2016, 8:03:26 PM6/21/16
to mod-pagespeed-discuss
Hi Jeffrey,

Thank you for your reply. 

I am having hard time in figuring out how to log the messages so that I would be able to see how the functions are working. Could you please help me with that? 

I tried apache logs, driver -> INFOHERE etc. But I am not able to see the log messages. 

Thank you so much. 
 

Joshua Marantz

unread,
Jun 21, 2016, 8:07:21 PM6/21/16
to mod-pagespeed-discuss
RE logging: try LOG(ERROR) << "whatever you like";
even if it's not really an error, that will make it into the apache log.  If you want to use INFO level, you can do that, just put
  loglevel info
into pagespeed.conf.  However, you'll get a lot of other noisy messages as well, as I usually debug with LOG(ERROR).

RE relative paths: can you describe in more detail the symptom you are trying to debug?  There might be a solution that does not involve debugging or customizing the C++.  What does the /wp-content/uploads/2015/10/home.jpg rewrite to and how is it wrong?

-Josh

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.

anir...@webscalenetworks.com

unread,
Jun 22, 2016, 10:56:14 AM6/22/16
to mod-pagespeed-discuss
Hi Josh,

Thanks for your reply. Here is the details of the problem that I am facing.


body {

    background: url("/wp-content/uploads/2015/10/home.jpg") no-repeat scroll center top;

    background: url("c-content/uploads/2015/10/home.jpg") no-repeat scroll center top;

    height: 100%

}


When the CSS is sharded, it is rewritten to a URL like http://shardhost/rxkey/wp-content/themes/brainstorm/style.css. The rxkey part is a key derived from the rx hostname to allow shardhost accesses to use the right backend hostname (the secondary alias).

To allow for relative URLs in the CSS (without a leading-slash), and to allow resources referenced by the CSS to be shareded as well, all URLs in the CSS that do not specify a hostname need to be rewritten.

When rewriting a relative URL (like c-content/uploads/2015/10/home.jpg) the reference is correctly rewritten as http://shardhost/rxkey/c-content/uploads/2015/10/home.jpg so that it accesses the backend with hostname rx. However, when rewriting the absolute URL (/wp-content/uploads/2015/10/home.jpg) for sharding, it incorrectly rewrites it relative to the origin URL, so ends up with http://shardhost/wp-content/uploads/2015/10/home.jpg (which should be http://shardhost/rxkey/wp-content/uploads/2015/10/home.jpg ) so that when the backend is accessed, it uses the primary alias as the hostname, which is incorrect and likely results in a 404.


anir...@webscalenetworks.com

unread,
Jun 22, 2016, 11:44:49 AM6/22/16
to mod-pagespeed-discuss
I am still not able to see the logs.
 
I tried doing LOG(ERROR) << "some string" ;.
 
I tried to check the latest log files. But I can not see any log messages. Could you please elaborate more on the logs? Thanks!

anir...@webscalenetworks.com

unread,
Jun 22, 2016, 12:31:25 PM6/22/16
to mod-pagespeed-discuss
I got how to log the messages! But I am still struggling with the absolute and relative urls. 

Thanks!
Reply all
Reply to author
Forward
0 new messages