Store URL Keywords in database, or derrive
If I have a book named "The Harold's Purple Crayon Collectors Set," I want the website URL to look like this:
www.site.com/book/harolds-purple-crayon/4324I will need to write code to strip out things like noise words, special characters, words less than x chars long, limiting the final result to y words, etc, bu开发者_运维技巧t after that code is written, what do I do with it?
Do I run each title through the code every time the URL is needed on my site, or instead, use the code to loop through all my titles and dump the results into a database and pull them from there instead of dynamically building them each time?
The best practice in this case is to save the friendly-URLs to the database and have them retrieved together with other information about that book (in this case). Next, all you have to do is to re-create the URL, using the string you generated and the ID (as per your example).
精彩评论