def is_immutable_file(self, path, url):
"""
Determine whether given URL represents an immutable file (i.e. a
file with a hash of its contents as part of its name) which can
therefore be cached forever
"""
if not url.startswith(self.static_prefix):
return False
name = url[len(self.static_prefix):]
name_without_hash = self.get_name_without_hash(name)
if name == name_without_hash:
return False
static_url = self.get_static_url(name_without_hash)
# If the static URL function maps the name without hash
# back to the original URL, then we know we've got a
# versioned filename
if static_url and static_url.endswith(url):
return True
return False
评论列表
文章目录