-
Notifications
You must be signed in to change notification settings - Fork 363
Conversation
What sort of problem were you having with pagespeed? Is this an attempt to fix the problem described in #102? |
Is the priority of pagespeed higher then others? If so it is yes. |
@yaoweibin any chance you could look at this? |
This looks very promising, I think it might fix #102, but I should test it more. Thanks for writing it! Could you sign our CLA? https://developers.google.com/open-source/cla/individual |
now the calling sequence is try_files > ps_content_handler > others, |
I had a look at the pull request, It saves the original first content_length handler and replaces it with pagespeed handler. It's the similar solution as Piotr Sikora did. @chaizhenhua can you look at the Piotr Sikora's patch and test your pull request. The test method can be found in the README of this project. Thanks. |
@yaoweibin where is Piotr Sikora's patch? |
the patch(FRiCKLE/ngx_cache_purge@822a28c) looks similar, i think there is following solutions to #102:
ps_create_request_context directly process the request so 3. is abandoned. I will test it. |
hello,
|
@chaizhenhua: "I test it use the commit 46055b4, there is a coredump if add two http block to nginx.conf." Confirmed, I can reproduce that, and am looking into it. To be honest, I was not aware that you could do that. Could you explain when is it practical to have two http{} blocks? |
With two http{} blocks, ps_create_main_conf gets to be called twice, which includes this code:
The static initialisers seem straightforward to fix by only calling them once; but I'm not sure how we should handle having two main conf's. For example, ngx_http_conf_get_module_main_conf is used later on, and will only return a single main configuration, while it seems we have created two of them in this case. Any thoughts? |
I just want to test pagespeed and do not want to change my nginx.conf, so i just paste testing config in front of nginx.conf. |
@yaoweibin is following message means OK?
|
I tried to build mod_pagespeed from source as the README, but failed at gclient runhooks. i can build the latest version follow the page(https://developers.google.com/speed/docs/mod_pagespeed/build_from_source), but can't pass the tests even use 46055b4. i seen some apache config files in mod_pagespeed/src/install, should i add more directives to nginx.conf to run the test? or should I configure something else? |
@chaizhenhua It may fail in some of tests. It's OK. You can see the note from README:
|
@@ -1919,11 +1985,11 @@ ngx_int_t ps_init(ngx_conf_t* cf) { | |||
ngx_http_core_main_conf_t* cmcf = static_cast<ngx_http_core_main_conf_t*>( | |||
ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module)); | |||
ngx_http_handler_pt* h = static_cast<ngx_http_handler_pt*>( | |||
ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers)); | |||
ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use the NGX_HTTP_ACCESS_PHASE
? You may break the access module.
My original idea of this problem was just move this pagepseed fetch content_handler to the last handler of the access_phase. And we don't need modify any of the code in the handler itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may break the access module? I don't know what you mean.
the ps_preaccess_handler just modify cfg_l->loc_conf / clcf and return NGX_DECLINED.
your idea is good and brief if we can determine the order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you seen this code?
https://github.com/agentzh/srcache-nginx-module/blob/master/src/ngx_http_srcache_fetch.c#L205
It's tricky.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i seen the code. put to access phase might be better. but i don't know why skip post access phase.
and in access phase, we only need to check r->phase_handler == ph->next - 1
in the handler.
It's a good idea. I think we can insert ps_content_handler with generic_phase checker before TRY_FILES phase.
@yaoweibin the patch has changed use the idea(https://github.com/agentzh/srcache-nginx-module/blob/master/src/ngx_http_srcache_fetch.c#L205 |
@@ -94,7 +94,7 @@ else | |||
$psol_library_dir/libapr.a" | |||
fi | |||
|
|||
pagespeed_libs="-lstdc++ $psol_library_binaries -lrt -pthread" | |||
pagespeed_libs="-lstdc++ $psol_library_binaries -lrt -pthread -lm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeffkaufman has fixed it in a new pull request ( https://github.com/pagespeed/ngx_pagespeed/pull/192/files), you could delete this commit.
with out
|
ngx_http_handler_pt* h = static_cast<ngx_http_handler_pt*>( | ||
ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use the access phase to move the handler? It could reduce the number of movement elements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add handler to access phase, nginx may add extre post_access_phase after access phase(see ngx_http_init_phase_handlers at http.c:460).
preaccess phase use generic checker, generic checker checks less then access_phase_checker, and it's enough for us.
the ps_preaccess_handler will be called only once, so the movements may be acceptable.
@jeffkaufman can you look at the link error with library m? |
@yaoweibin "can you look at the link error with library m?" There was also just an error on the mailing list about |
while (ph[i + 1].checker != ngx_http_core_try_files_phase | ||
&& ph[i + 1].checker != ngx_http_core_content_phase) { | ||
ph[i] = ph[i + 1]; | ||
ph[i].next --; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coding style:
ph[i].next--;
It looks good to me. |
i++; | ||
} | ||
|
||
// insert content handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trailing whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
The code is good and looks like it's doing the right thing, but I want to make sure it handles each of the cases properly before I merge it. I tested with
What other configurations should I test? Could someone give an example usage of |
That's decent. The different process phase test cases should be added in this change:
All the phases could be simple and primary usage. |
This fails in the rewrite_images system test:
wget -q --header=ModPagespeedFilters:rewrite_images -H -p -S -o /tmp/mod_pagespeed_test.jefftk/fetched_directory/wget_output.txt -nd -P /tmp/mod_pagespeed_test.jefftk/fetched_directory -e robots=off http://localhost:8050/mod_pagespeed_example/rewrite_images.html and checking with grep -c .pagespeed.ic To reproduce, run this command and note that it hangs:
|
It's trying and failing to download |
I think the problem is probably the |
Why are we putting an 404 page at the end of the response? |
I just confirmed that the 404 page appending doesn't happen on |
Because the 404 page is beyond the content length |
@chaizhenhua Can you look at this broken test case? |
Another problem I found is that on my machine the second requests seem to hang when using proxy pass.
And then try to fetch a pagespeed resource 2 times from it using keep-alive, for example:
The second request here will hang. After debugging a little, disabling the line at https://github.com/pagespeed/ngx_pagespeed/blob/master/src/ngx_pagespeed.cc#L2005 seems to fix this particular problem. However, this still needs some research as doing that probably breaks something else, plus I'm having trouble understanding the exact sequence of events here. |
@yaoweibin OK. I'm working on it. |
@oschaaf disable (https://github.com/pagespeed/ngx_pagespeed/blob/master/src/ngx_pagespeed.cc#L2005)
|
@chaizhenhua no, those are expected failures and not related to this. In place resource optimization is not implemented yet, and the other tests fail because we currently send out the response headers too soon to be able to support the related pagespeed filters. |
|
Removing the |
Testing a configuration from #201, it looks like we still don't work with
which is the content of Without the
as we should. Is this expected behavior? Should this patch be able to get in ahead of those |
@jeffkaufman
|
hi, all, if other nginx module use |
Ooh;m good catch! I've moved this to a separate issue: #202 |
ps_content_handler should be called before other content handler.