-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
good first issuejavascriptPull requests that update Javascript codePull requests that update Javascript codepythonPull requests that update Python codePull requests that update Python code
Description
This is a bad cache
packet/packet/context_processors.py
Lines 58 to 70 in f61cd2b
@lru_cache(maxsize=256) | |
def get_rit_image(username: str) -> str: | |
if username: | |
addresses = [username + '@rit.edu', username + '@g.rit.edu'] | |
for addr in addresses: | |
url = 'https://gravatar.com/avatar/' + hashlib.md5(addr.encode('utf8')).hexdigest() + '.jpg?d=404&s=250' | |
try: | |
gravatar = urllib.request.urlopen(url) | |
if gravatar.getcode() == 200: | |
return url | |
except: | |
continue | |
return 'https://www.gravatar.com/avatar/freshmen?d=mp&f=y' |
It caches the first call to this function for any given username (up to 256 of them) via functools.lru_cache
, which is bad, because it kinda defeats the point of gravatar.
We could do some form of caching, but probably shouldn't. Loading these images lazily in the frontend would probably be much better.
At the very least, please remove the cache so we can stop kicking the pods to have photos update.
Metadata
Metadata
Assignees
Labels
good first issuejavascriptPull requests that update Javascript codePull requests that update Javascript codepythonPull requests that update Python codePull requests that update Python code
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity