I am making a web application where people can like and favorite vegetable descriptions, they can also like other peoples vegetable journals. When a user opens a seed description page the like button should be active if the user has already liked this particular page in the past. Now there are 2 ways of doing this:
When the information of the vegetable description is gathered from the database the server also looks in the likes table to see if the user has already liked this page or not. This should then be signaled with a boolean set to true, same goes for favorite.
On login the entire like/dislike/favorite history of the user is downloaded and kept in localstorage in the browser. This way the server doesn't have to check whether a particular page has been liked favorited each time when information for that page is retrieved. If someone likes/favorites thousands of pages (which is then stored as thousands of vegetable description ids in the browser) then retrieving the entire history at once may be a bit costly, but then again lookingup and signaling everytime a page request is made is costly too in terms of bandwidth and database search time.
So which of the 2 options should i choose?