Only connect to a database if necessary


Triggering a connection to a database server is resource intensive for the application server, the database server, and, potentially, for the network. Do not use the database if the application doesn’t need it.

Dynamic tools often generate 404 pages for resources (CSS, JavaScript, images, etc.) which cannot be found in the file system. These 404 pages are generated once the CMS has checked that the database has no content matching the requested URL.
It is therefore wise to implement rules that stop database searches (and thus connecting to the database) for URLs that contain extensions such as *.css, *.js and *.png,

This best practice should only be applied if it is coherent with your project's specifications.
Under CC-By-NX-SA license