Hello,
I'm programming an Amazon type web site and find myself "wasting" a
lot of time writing code that gets information from include files
rather than from the database because I have this notion that it will
avoid clogging the db when many users come to the site. My main goal
anyway is to have the user wait as little as possible because that's
good for business apparently.
Here's an example:
When the user will be checking out a certain product I'll have to
display at the top of the page the product category path. For instance
Products > Electronics > Computers > Laptops > Accessories > Mouse
If I wanted to code quickly I could write a function that builds this
path by querying the database and run the function every time someone
accesses a page. Instead I have a folder "Paths" containing an include
file for every category possible. For example: "path_category_32.inc".
In my web page I do something like
include("path_category_".$_GET['cat_id'].".inc");
and the file contains:
echo "Products > Electronics > Computers > Laptops > Accessories >
Mouse";
I have code that generates these include files and I only have to run
it when a category is added, removed or renamed - which will be rare.
Is this not a lot better than querying the database 1000 times a day
just to get information that is static? Now this was one example but
there are many other elements I could apply this method to. The
problem is that it takes a lot longer time to code and I also have a
delivery date to meet, yet I don't want to deliver something that is
not efficient because it queries the db all the time.
Any advice?