Has anyone gotten browser caching to work for static files?  I get
nice 304s for the images/stylesheets/javascript, but I'd really like
the browser to stop asking for them on every request.

My middleware.py line is:


    javascripts_app = StaticJavascripts()
    static_app = StaticURLParser(config['pylons.paths']['static_files'],
        cache_max_age=3600)
    app = Cascade([static_app, javascripts_app, app])

I also tried setting up caching for a text file served by a controller
but ran into the same problem.  Beaker cache works, 304 may or may not
work, but browser caching does not.  Here are the beginnings of two
actions which are in production.  They were written before Pylons
0.9.6 so I didn't fully convert the etag syntax to the global response
object before I gave up.

===
    @beaker_cache(key=None, expire=config["cache.data"], type="file",
        query_args=False)
    def map_markers(self):
        """Return a tab-delimited text file containing incident information
           for the Google Maps interface.  Called via Javascript.
        """
        encoding = "utf-8"
        #etag_cache("map_markers")
        response.headers["content-type"] = "text/plain; charset=%s" % encoding
        response.headers["cache-control"] = "public, max-age=%s" %
config["cache.data"]
        response.headers["pragma"] = ""
       ...
===
    @beaker_cache(key=None, expire=config["cache.data"], type="file",
        query_args=False)
    def all_incidents(self):
        #resp = etag_cache("all_incidents")
        #resp.headers["cache-control"] = "public, max-age=%s" %
config["cache.data"]
        ...
===

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to