Cache should be cleared before rebooting with new code

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the caching category.

Last Updated: 2024-04-13

In your deploy process, you should, at the very least, clear the cache before the latest version of your code is used (it usually gets used when you restart your server). This is because you don't want your server process reading from old cached data that might be incompatible with the updated code, for example because it references data fields that no longer exist.

I had this issue in Semicolon&Sons when I restarted my server after changing the shape of my series data JSON. This threw an exception, since the cached data contained a published_on field whereas the updated code had removed it.