Hello from mod_pagespeed again. Our users have identified another incompatibility between standard filters and mod_pagespeed; this time with mod_includes. In general I think that mod_pagespeed should run after mod_includes, for a few reasons. But in particular, mod_pagespeed, in its own html-centric filter architecture, has a 'remove_comments' filter which strips out any server-side includes if mod_pagespeed runs prior to mod_includes. While 'remove_comments' is an optional feature for mod_pagespeed (many web pages would be broken without mod_pagespeed), many consider it a desirable feature they'd like to turn on.
This is all documented at length in http://code.google.com/p/modpagespeed/issues/detail?id=182 Even in the absence of 'remove_comments', it would be preferable to have mod_pagespeed run after mod_includes so that it has an opportunity to optimize the included text. The user can achieve this by putting this line into his config file: AddOutputFilter INCLUDES;MOD_PAGESPEED_OUTPUT_FILTER html But this is not desirable for a couple of reasons. We'd like to force the correct order automatically if possible. The question for this mailing list is how best to achieve that. Should we, in mod_pagespeed's output filter, have logic that says: if (mod_includes was enabled in this config) { re-insert mod_pagespeed at the end of the AP_FTYPE_RESOURCE chain pass the buckets to mod_includes } Or can we, at init time, call server APIs to tweak the filter order? Is there any filter that seeks to do that somehow? We also have a constraint that mod_pagespeed must run before mod_deflate. Actually mod_pagespeed already inserts mod_deflate in the filter-chain to run downstream of it: ap_add_output_filter("DEFLATE", NULL, request, request->connection); Another hack is to have mod_pagespeed introduce a new output filter, MOD_PAGESPEED_REORDER which would: remove INCLUDES remove MOD_PAGESPEED_OUTPUT_FILTER add INCLUDES add MOD_PAGESPEED_OUTPUT_FILTER This seems ugly though because (a) I don't know how to remove a filter by name and (b) it would wind up adding INCLUDES even if it was not already registered. A third idea is to exploit the fact that INCLUDES adds itself to the output chain via ap_hook_fixups(include_fixup, NULL, NULL, APR_HOOK_LAST); where include_fixup() does ap_add_output_filter("INCLUDES", NULL, r, r->connection); I suppose mod_pagespeed could set up its own call to ap_hook_fixups(niod_pagespeed_fixup, NULL, NULL, APR_HOOK_LAST* + 1*); and add itself as an output filter. But all of these ideas seem like a hack. Any hints on how to enforce the output-filter ordering: INCLUDES,MOD_PAGESPEED,DEFLATE in a robust and clean way, would be greatly appreciated. -Josh