# Adding header/footer to gzip'ed html files

**URL:** <https://www.ruby-forum.com/t/adding-header-footer-to-gziped-html-files/228564>\
**Category:** NGINX\
**Created:** [April 27, 2013, 7:41pm UTC](https://www.ruby-forum.com/t/adding-header-footer-to-gziped-html-files/228564 "2013-04-27T19:41:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Constantine\_ASMure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3ec8ea/32.png) [@Constantine\_ASMure](https://www.ruby-forum.com/u/Constantine_ASMure)\
**Post date:** [April 27, 2013, 7:41pm UTC](https://www.ruby-forum.com/t/adding-header-footer-to-gziped-html-files/228564/1 "2013-04-27T19:41:59Z")

</div>

Hello,

I’m trying to see ways in which OpenGrok could be optimised with nginx.

One of the ideas I have is using nginx to serve the /xref/ pages,  
instead of them going through OpenGrok each time. OpenGrok (the  
indexer) pre-generates the body of the /xref/ pages, and stores the  
resulting html as .gz files, but those files don’t have any  
header/footer, and require to be presented within “

```
” and “
```
”,  
which OpenGrok (the webapp) then adds on the fly.

Would it be possible to use `add_before_body` and `add_after_body`  
([http://nginx.org/docs/http/ngx\_http\_addition\_module.html](http://nginx.org/docs/http/ngx_http_addition_module.html)), together  
with `gzip_static always`  
([Module ngx\_http\_gzip\_static\_module](http://nginx.org/docs/http/ngx_http_gzip_static_module.html)), together  
with `gunzip on`  
([Module ngx\_http\_gunzip\_module](http://nginx.org/docs/http/ngx_http_gunzip_module.html)), to replace  
passing /xref/ to OpenGrok (the webapp)?

Technically, gzip / deflate is a stream encoding, so, supposedly,  
there’d be no need to decode and re-encode the .gz files, but some  
special handling will probably still have to be performed nonetheless.

I presume a scenario as above would not currently work (but I might as  
well be wrong); however, does this sound like something that’s  
potentially interesting, and not overly difficult and complicated to fix  
up? Or would it be simpler to amend all the /xref/ pages for all of  
them to redundantly include the needed header and footer?

Cheers,  
Constantine.
