I have a search page that allows the users to filter other users by various categories (age, gender, country, region, ethnicity, etc). The first time the search function is called it gets all the possible values for each category from the database. Just wondering though...
Is it better to POST this data back each time the page is re-loaded (in a serialized hidden form field) or should I retrieve this information from the database every time the page is loaded.
If i understand the situation correctly, the serialized POST option would increase the sites bandwidth consumption as the data is traveling from the users machine, to the server and back to the users machine again. On the other hand, querying the database everytime would increase the load on the server/database, but would only use half the bandwidth.
If thats the case, what option should I go for... I know that it probably doesn't make much difference for the amount of traffic i'll be getting, but I want to learn the best methods of doing this sort of stuff :P
Generally, I would always keep things under your own control. Which means keeping it between your server and your database.
You have no control over the speed of a user's internet connection, or network latency etc.
Also, if you want to keep things between requests, have you thought about using sessions or cache? A cache, such as APC would allow you to store the data on the server for the next request, so it needs neither Database or bandwidth.