The message history is stored server side. If you log into the client and open a space, it will download and keep the data also in an own database file.
As spaces are continous, the history will be kept according to your organizations retetntion policy. A space's history will also be deleted if there are no more people in the space, ie. if everyone left the space.
Please be aware that this only refers to spaces. Chat histories from within meetings are not persisted.