I am trying to make a method which would reduce sql requests to speed things up a little bit. My idea was:
- Make 1 request from the mysql-db
- place data into LocalStorage (json)
- If there is something in the LocalStorage, work from there instead of making a new db request
- When serving values from LocalStorage add +1 in the LS "view" column
- When "view" reached a certain number, make a new sql query refreshing the current LocalS and UPDATE the mysql db with the view number.
The problem is that somebody could overwrite the current view and it would then make false viewcount.
I was thinking about making a little token so it updates everytime when the viewcount changes, however it could be seen on javascript side.
Should I just make queries everytime when a page is loaded (Wouldn't it slow the site down?) or should I use a db like redis? I expect about ~1000s of users or more.
Thank you very much in advance, all ideas are highly appreciated.