Contributions

Other (Category Index)
Search: 

Faster Page Loads, Less DB queries

This contribution is to help with page loading times, and with DB queries. Every time a page loads osCommerce,
PHP pulls every row from the configuration table in the database. That's over 170 rows every time, every page load.

I decided to be daring, I am sure against osc developers wishes, but I think this is worth mentioning.

PLEASE KNOW WHAT YOU ARE DOING AND HOW TO HANDLE FILE PERMISSIONS AND REMEMBER TO BACKUP FIRST!!!


How it works:

Every time someone edits a configuration from the configuration box in admin and hits "save" or "submit", the script writes a php file in the folder of your choice (preferably outside the www root) with all the configs from the database. Then, when each page loads, it calls all these configs as an include file, already pulled from the database, instead of querying the database each time and performing the function. I noticed improvement in page load times. Here are some page parse times:

before this change:
08/02/2004 01:55:25 - /index.php?cPath=13 (0.198s)

after the change:
08/02/2004 01:56:14 - /index.php?cPath=13 (0.092s)

Expand All / Collapse All

Configuration Cache 1.32b - Minor bugfix Phliplip 20 May 2007

While fooling around i found that the modules.php could insert a row in the configurations table
with an empty configuration_key, resulting in the cache function inserted;

define('', '');

Thus the cached config file got currupted and issuing an error both in catalog and admin.

To handle this and to secure other contribs don't imply this error, please replace following line;

$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);


With;

$configuration_query = tep_db_query("select configuration_key as cfgKey, configuration_value as cfgValue from " . TABLE_CONFIGURATION . " where configuration_key != ''");

The file to download is just a dummy textfile, containing this text. No more no less.

Best Regards,

Phliplip ;)

Configuration Cache 1.32 Christophe B. 30 Aug 2004
minor bug Emmanuel Arnaiz 14 May 2004
Configuration Cache v1.31 DaemonJ 13 May 2004
Configuration Cache v1.30a DaemonJ 15 Apr 2004
Configuration Cache v1.30 DaemonJ 14 Apr 2004
Configuration Cache v1.20 DaemonJ 6 Apr 2004
Contribution Cache v1.10 DaemonJ 6 Apr 2004
Configuration Cache v1.01 corrected for MS1 DaemonJ 5 Apr 2004
Configuration Cache v1.01 DaemonJ 4 Apr 2004
Faster Page Loads, Less DB queries Joseph Passavanti 9 Feb 2004
Faster Page Loads, Less DB queries Joseph Passavanti 8 Feb 2004

Note: Contributions are used at own risk.