[Grok-dev] Enable gzip/http compression in Grok/Zope site

Danny Navarro j at dannynavarro.net
Mon Aug 2 12:39:59 EDT 2010


On Mon, Aug 2, 2010 at 5:52 PM, Hector Blanco <white.lists at gmail.com> wrote:
> Hello everyone...
>
> I would like to know how I can send compressed data from my server
> (using Grok/Zope3).

HTTP compression should be done by the HTTP server. For Apache, for
example, you can enable mod_deflate in the Apache configuration file.
http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

I think most distros have it enabled by default.

>
> I am using TAL templates to generate the HTML. For instance:
>
> (template in file test.pt)
> -----------------------------------
> <html>
>        <head>
>                <title>TEST</title>
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/forms.css" />
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/layout.css" />
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/nav-horizontal.css" />
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/plugins.css" />
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/tools.css" />
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/typo.css" />
>                <link rel="stylesheet" type="text/css" tal:attributes="href
> static/css/colorpicker.css" />
>
>                <script type="text/javascript" tal:attributes="src
> static/js/jquery-1.4.2.min.js"></script>
>                <script type="text/javascript" tal:attributes="src
> static/zjs/myutil.js"></script>
>                <script type="text/javascript" tal:attributes="src
> static/zjs/myincludes.js"></script>
> -----------------------------------
>
> When the user goes to: http://127.0.0.1:8080/my-application/test ,
> this is handled in app.py by:
>
> class Test(grok.View):
>        grok.context(Grokserver)
>        grok.require('viewsite')
>
> I would like to know if I can easily send some (or all) of the
> information compressed in gzip. The information generated by the
> template is huge, and any compression would be helpful.
>
> If I could get to send the .js files compressed with gzip, it would be
> a great improvement (or even better: if I can send the "test" page in
> gzip)
>
> I've been googling a lot and I haven't seen any good way to send
> compressed data.
>
> Thank you in advance!
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>


-- 
Danny Navarro | http://dannynavarro.net


More information about the Grok-dev mailing list