CDN Help with Pagespeed Configuration (Origin)

88 views
Skip to first unread message

praveen kumar

unread,
Mar 29, 2014, 11:23:59 AM3/29/14
to ngx-pagesp...@googlegroups.com
Hi,

I am trying to setup cdn for our static assets. However, I am not able to work. I am using https.


requirements
<img src="/img/xxx"> should be rewritten to <img src='https://cdnssl.mysite.com'/>

pagespeed on;

pagespeed RewriteLevel CoreFilters;

pagespeed FileCachePath /tmp;


pagespeed Domain https://www.mysite.com;

pagespeed Domain https://cdnssl.mysite.com;


pagespeed ModPagespeedLoadFromFile "https://www.mysite.com/" "/home/ubuntu/agile/www/nice/";


#cdn settings

pagespeed MapRewriteDomain "https://cdnssl.mysite.com/" "https://www.mysite.com/";



It's working ok till now without much issues.

<img src='https://cdnssl.mysite.com/img/logo.png.pagespeed.ce.c5tSiF9tkZ.png' alt="logo" style='max-height:28px' pagespeed_url_hash="1660387230"/></a>

I see two issues here .. first the image is already optimized but it is giving me a png too. I downloaded both this and compared original. Same bytes. diffed too. Same. I am not sure why is it trying to optimize an image and changing its name when it is same. It's bad from SEO front.


2. Logging.. where is the command line logs to figure out the issue of authorized domains.. which domain should I add?
Writing to ngx_pagespeed_message failed. Please check if it's enabled in pagespeed.conf.

Otto van der Schaaf

unread,
Mar 29, 2014, 4:19:35 PM3/29/14
to ngx-pagesp...@googlegroups.com
First - this configuration line looks wrong to me:

pagespeed ModPagespeedLoadFromFile "https://www.mysite.com/" "/home/ubuntu/agile/www/nice/";

Are you sure nginx is starting up OK with that? You probably meant something like:
pagespeed LoadFromFile "https://www.mysite.com/" "/home/ubuntu/agile/www/nice/";

One thing I have seen is that sometimes CDN's catch the partially optimized image from the first request - and cache that for some time. That might cause you to see a .pagespeed. optimized png equal in size to the original. Could you purge and recheck?

On 2.
Adding this to nginx.conf's http{} block should enable /ngx_pagespeed_message:
pagespeed MessageBufferSize 100000;

Otto


--
You received this message because you are subscribed to the Google Groups "ngx-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/d/optout.

praveen kumar

unread,
Mar 30, 2014, 1:14:19 AM3/30/14
to ngx-pagesp...@googlegroups.com
Hi Otto

Thanks for your quick note. 

ModPagespeedLoadFromFile strangely worked for me many times and nginx doesn't complain. My gut says that modpagespeed is just taken out while comparing. So, it's eventually the same. I changed it to LoadFromFile to be syntactically correct. It makes no difference.

1. 
The issue is not with CDN caching but page speed in the first attempt trying to compress the image (or adding the cache path) which is already compressed. I am not sure why it would be rewriting with 

If I disable
 # trying to disable this for seo to avoid the page extension but cannot make it to work

pagespeed DisableFilters rewrite_images;


The doesn't map domain to cdnssl.mysite.com and leaves /img/logo.png as is and doesn't touch it.


I tried with recompress_images too, same issue. It still shows https://cdnssl.mysite/img/logo.png.pagespeed.ce.c5tSiF9tkZ.png


Diffing is same results. I am assuming that it is doing a round trip instead of reading from local directory.


2. pagespeed MessageBufferSize 100000; is already there but it still complains.. I think it's a bug in ngx_pagespeed-1.7.30.3-beta/ .. is there a way to check in the log files.. I do not see anything in /var/log/nginx or /var/log/nginx

Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsub...@googlegroups.com.

Otto van der Schaaf

unread,
Mar 31, 2014, 3:33:38 PM3/31/14
to ngx-pagesp...@googlegroups.com
Urls like https://cdnssl.mysite/img/logo.png.pagespeed.ce.c5tSiF9tkZ.png are still being rewritten because of the extend_cache filter being enabled (the url contains .ce.).
Adding pagespeed DisableFilters extend_cache should help, but disables it for other resources too.

You could also try disallowing paths that you want to be left alone, which allows more control:

I am able to reproduce the problem with /ngx_pagespeed_message, and added https://github.com/pagespeed/ngx_pagespeed/issues/650 for it.

Meanwhile, configuring nginx's error_log to info or debug [1] will output (a lot!) more info 
to nginx's logs, and might give hints about domain authorization rejections when you need it.
Note that this might cause your logfiles to grow very rapidly (and slow down your server), so don't forget to turn the error_log level back when you are done.


Otto


To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.

Otto van der Schaaf

unread,
Mar 31, 2014, 4:29:01 PM3/31/14
to ngx-pagesp...@googlegroups.com
With regard to /ngx_pagespeed_message failing - I might have a workaround at https://github.com/pagespeed/ngx_pagespeed/issues/650, which involves explicitly
configuring a shared memory cache.

Praveen could you try it (temporarily)? To confirm you are experiencing the same issue?

More on the shared memory cache:

Otto


On Sun, Mar 30, 2014 at 7:14 AM, praveen kumar <pbx....@gmail.com> wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.

praveen kumar

unread,
Apr 1, 2014, 7:22:29 AM4/1/14
to ngx-pagesp...@googlegroups.com
Thanks.

1) 
- does it extend all images? Disabling extend_cache went away but brought in 

For some images, it's not writing the map domain
src="/img/xxx.png"

2) I tried pagespeed CreateSharedMemoryMetadataCache "/var/cache/pagespeed/" 51200; with the correct directory and it doesn't do anything. I still get the same error. Writing to ngx_pagespeed_message failed. Please check if it's enabled in pagespeed.conf.

To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-discuss+unsubscri...@googlegroups.com.

Otto van der Schaaf

unread,
Apr 1, 2014, 8:19:59 AM4/1/14
to ngx-pagesp...@googlegroups.com
- does it extend all images? Disabling extend_cache went away but brought in 
https://cdnssl.mysite.com/xxx.png.pagespeed.ic.mgwE5lowAi.jpg what is Ic

"ic" stands for image compression - I would expect that the .pagespeed. version of this image is smaller then the original.
If that is what you want I suggest you leave it like that. 
 
For some images, it's not writing the map domain
src="/img/xxx.png"

If you want to apply domain rewriting to all js/css/images, you need to enable the rewrite_domains filter. 

I tried pagespeed CreateSharedMemoryMetadataCache "/var/cache/pagespeed/" 51200; with the correct directory and it doesn't do anything. I still get the same error. Writing to ngx_pagespeed_message failed. Please check if it's enabled in pagespeed.conf. 

In you first email you had something different - are you sure the path is correct?:
pagespeed FileCachePath /tmp

If you are able to build from source: I can't reproduce the problem with /ngx_pagespeed_message when I build nginx with the tip of the master branch at https://github.com/pagespeed/ngx_pagespeed

Otto




To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.

praveen kumar

unread,
Apr 1, 2014, 9:41:43 AM4/1/14
to ngx-pagesp...@googlegroups.com
Thanks Otto.

1. It's rewriting domains correctly now with the filter
2. #logging

pagespeed Statistics on;

pagespeed StatisticsLogging on;

pagespeed LogDir /var/log/pagespeed;

pagespeed MessageBufferSize 100000;

pagespeed FileCachePath /var/ngx_pagespeed_cache/;

#pagespeed MemcachedServers "localhost";

pagespeed CreateSharedMemoryMetadataCache "/var/ngx_pagespeed_cache/" 51200;


I have put the right directory for createsharedmemory but I have the same issue.


Thanks.

Reply all
Reply to author
Forward
0 new messages