make_static_url disable hash override #447

Closed
docyes opened this Issue Jan 27, 2012 · 2 comments

Projects

None yet

2 participants

@docyes
docyes commented Jan 27, 2012

I have a use case where I need to tell static_url to not append the v/hash for cache/busting (prefer to leave that to the client).

It would be nice to add support for an override to disable cache busting as an optional kwarg hash that defaults to True:
def make_static_url(cls, settings, path, hash=True):

@bdarnell
Member

Originally the versioning was the entire point of static_url - if you needed a non-versioned form of a static url you'd just build the string "/static/%s" by hand. StaticFileHandler and static_url are more customizable now, so it's more useful to be able to combine different pieces of its functionality and not do things by hand all over the place, but it still feels a little weird to disable such a major piece of the method's functionality.

I think if we do something here, it would have to be a way to pass arbitrary **kwargs from RequestHandler.static_url to StaticFileHandler.make_static_url, since StaticFileHandler subclasses may not have a way to generate an unversioned url (consider a scheme that looks like "/static/%(version)s/%(filename)s"), and I don't think we want to make that part of the expectation for subclasses.

If we put a name on the default StaticFileHandler rule then you could use reverse_url("static", filename) to get an unversioned url along with static_url(filename) to get a versioned one. It's a little ugly to use two different methods for closely-related functionality, but it is a less-intrusive change.

@bdarnell
Member

I've merged #452 which adds an include_version kwarg to static_url.

@bdarnell bdarnell closed this May 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment