i tried use encodingresourcewrappper , gzipencoderfactory gzip twisted web server responses.
this seems work files. can not serve javascript files later loaded via requirejs. (the browser (chrome or firefox) keeps spinning.
the files serve fine, when enter javascript source path url. [updated: no, because came out of browser cache]
the files serve fine appengine (which gzips them).
class sharedroot(resource.resource): """root resource combines 2 sites/entry points""" wsgi = none def getchild(self, child, request): request.prepath.pop() request.postpath.insert(0, child) return self.wsgi def render(self, request): return self.wsgi.render(request) def render_post(self, request): logger.debug(pformat(request.__dict__)) newdata = request.content.getvalue() logger.debug(newdata) return '' class wildcardresource(resource.resource): def __init__(self, childresource): resource.resource.__init__(self) self.childresource=childresource def getchild(self,child, request): return self.childresource class gzipfileresource(static.file): def getchild(self, path, request): child = super(gzipfileresource, self).getchild(path, request) return encodingresourcewrapper(child, [gzipencoderfactory()]) class dynamicfile(gzipfileresource): def render_get(self, request): request.setheader("cache-control", ["no-cache"]) request.setheader("pragma", ["no-cache"]) request.setheader("expires", ["sat, 26 jul 1997 05:00:00 gmt"]) return super(dynamicfile, self).render_get(request) shared=sharedroot() shared.wsgi=encodingresourcewrapper(wsgiresource,[gzipencoderfactory()]) shared.putchild("static",gzipfileresource("static")) shared.putchild("css", gzipfileresource("static/css")) shared.putchild("js",wildcardresource(gzipfileresource("source"))) any ideas?
updated:
traces , debugging have shown, problem occurs script files > 64 kb, first call gzip compression object returns gzip header (that can see in network trace) , 2nd call returns nothing (because rest of compressed output happen flush call (that can not see in network trace)).
testing increased buffer size (of abstract.filedescriptor) did not solve problem
Comments
Post a Comment