Use asset fingerprinter to serve images

This means we can cache them forever, and only invalidate the cache
when the image changes.
This commit is contained in:
Chris Hill-Scott
2018-11-29 14:28:29 +00:00
parent 5bf6bdcd20
commit 643dca0071
5 changed files with 15 additions and 16 deletions

View File

@@ -1,4 +1,3 @@
import codecs
import hashlib
@@ -37,11 +36,11 @@ class AssetFingerprinter(object):
def get_asset_fingerprint(self, asset_file_path):
return hashlib.md5(
self.get_asset_file_contents(asset_file_path).encode('utf-8')
self.get_asset_file_contents(asset_file_path)
).hexdigest()
def get_asset_file_contents(self, asset_file_path):
with codecs.open(asset_file_path, encoding='utf-8') as asset_file:
with open(asset_file_path, 'rb') as asset_file:
contents = asset_file.read()
return contents