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:

  1. 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.

  2. 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?

Thank you

New contributor
Maurice is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    You need to decide what criteria you're using to evaluate your options. Most would choose simplicity of implementation first, then complexity only if warranted by performance data. In case it isn't clear, both caching data on the client side and integrating that cached data into your server-provided webpage seems more complex than simply serving the webpage. – Erik Eidt Jan 9 at 20:01

Your Answer

Maurice is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.