-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow transparent compression #19
base: master
Are you sure you want to change the base?
Conversation
limitations: list of supported extensions is hard-coded cached compressed file lives where the source file lives (i.e. not a separate cache directory). this means that apache must be able to write there
I'm not interested in hacking gzip into mod_xsendfile. What would be a viable option instead is using mod_deflate and making sure it works in tandem with mod_xsendfile. Right now that does not seem to be the case, as the XSENDFILE filter is inserted after all other filters. static void ap_xsendfile_insert_output_filter(request_rec *r) {
...
ap_filter_t *deflate = ap_get_output_filter_handle("DEFLATE");
if (deflate) {
if (deflate in r->output_filters) {
remove deflate from r->output_filters; /* to be re-inserted later */
}
else {
deflate = NULL; /* should not be (re-)inserted later */
}
)
/* current implementation */
ap_add_output_filter(
"XSENDFILE",
NULL,
r,
r->connection
);
/* reinsert filter behind XSENDFILE again */
if (deflate) {
ap_add_output_filter_handle(
deflate,
NULL,
r,
r->connection
);
}
} |
I might be misunderstanding what you're saying, but i don't think that would work because xsendfile passes the file directly to the OS which sends it to the socket. Meaning there's no chance for deflate to run properly; either deflate's output would be dropped on the floor or both deflate and xsendfile would send a response back to the user. In any case, you wouldn't want deflate to run since that means your not only compressing the same static content over and over again (wasting CPU cycles) but you're also copying the static files into user space to compress them in the first place, which defeats the behavior mod_xsendfile is trying to achieve in the first place, right? On Jul 26, 2012, at 6:28 AM, Nils [email protected] wrote:
|
tl;dr
Actually, mod_xsendfile only prepares the data structure that the server might use to pass over data to the socket or might instead pass on to the next filter in line (although, the current code kinda forces XSENDFILE to be the last filter ATM). I'm pretty sure mod_xsendfile can be made working in tadem with mod_deflate.
Yep, that assessment is mostly right.
Having that said, mod_xsendfile + mod_deflate would still perform better with less buffers involved than having php or whatever read the file into a VM buffer, transforming it, copying it over to an apache buffer (or network buffer, if run outside of the apache process e.g. via fastcgi/wsgi) and having apache serve that. The code from your pull request might actually be a lot better for your use case, however I wouldn't merge it because:
The first point is a show-stopper... Hence, I'd consider the later point my input for designing a dedicated module. |
Maybe I wasn't clear, but I definitely wasn't expecting this to be taken as is (as you point out & the blog post mentions, there's all sorts of problems with the code as is). It was more of a here's one approach I took, what do you think the approach should be kind of pull request. |
As I stated, I'd be willing to pull any integration with mod_deflate or any other compression module[1], but I'm not willing to integrate actual gzipping of any kind into mod_xsendfile, as this would be out of scope of this module. |
I just wanted to link to a few solutions I recommended for this module's compression problem. #36 (comment) |
this is a fairly hard-coded version but works as a proof of concept; would love to have feedback on how to fix this up to be mainlined.
https://wifislam.wordpress.com/2012/07/26/apache-sendfile-and-static-files/ for the analysis behind this patch.