Open codeblech opened 2 weeks ago
lmao
image index needs to be updated in the server.
in magazine/models.py
there is a function fetch_index
that is run on startup and declares a variable image_index
this variable is then used in views.py
We need to implement a cache invalidation system.
One approach I have in mind is to push a small file in the cdn which contains a timestamp or hash.
The server can then periodically poll that file to see if it has changed and refetch the index accordingly.
Or if we don't want overhead of a worker thread. We can do this when someone request a page from the server. Something like if a certain time has passed till the last poll and someone has requested a webpage then poll again.
The latter might induce a little latency if there is a change in cache index, but it has the added benefit of less overhead and we won't have to deal with mutexes.
django has a framework for caching. i'm trying that out
This behavior is typical because Python/Django modules are loaded once when the server starts, and any code outside of functions or classes will not be re-executed until the server reloads.
This means that the index is fetched from your CDN and cached in memory when the server is initially loaded, but it won't be updated automatically unless the server is restarted or the code to fetch the index is triggered again.