I want to know when to use URL query params to pass data between pages vs querying the database directly, and what the best practices around this is. Here's my specific scenario:
I have a site where, if users solve a puzzle, I redirect them to a url like this:
The message_code signals the kind of message they should receive ("you've earned all the points!", "you earn half points because you had more than 5 incorrect answers", etc). And the puzzle_id is used to populate some puzzle-specific data/responses. The answer_id is a user specific and puzzle specific id for this given instance.
However, I could get all this data by just include the answer_id param in my url and then querying my answers table for the puzzle_id and message_code values. Then my url would just be this:
My current logic is that if I can pass it in the url and avoid a database call, that would be better/faster, but I'm curious what the general industry standard is. Is there a best practice around how much/when to put non sensitive data into url params?
Aucun commentaire:
Enregistrer un commentaire