Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

To cache or not to cache


PVK

Recommended Posts

My shop has been running fine for quite some time, but the cache feature has always been turned off untill now, since i really like to know if it would be wise to turn this function on.

 

I have been searching thru the posting but can't get a satisfying answer .

 

Should i turn it on or are there problems to be expected ?

What is better cache on or cache off ?That's the question?

 

 

Thanks in advance

Link to comment
Share on other sites

Hell yes turn it on...it'll save anywhere from 25-75% of the per page queries, decrease server load tremendously, and ultimately speed up the per page times.

 

Bobby

Link to comment
Share on other sites

And sometimes lead to issues of others osC categories being displayed on your site.....this does not always happen...but it does frequently enough for me to remember it being discussed on the forums here several times anyways....

 

Unless your site is heavy trafficed, the speed up issue is a non-starter, what is a 1/4 sec tops of time saving?

 

cheers,

 

Peter M

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

If you have your cache directory setup properly that is never an issue. The problem comes up when on a shared server (which most are) and the default is to save everything in the /tmp/ directory. If multiple osC stores are on that server and all are saving files to that directory then cross info will be an issue.

 

However, if you create your OWN cache directory and use that path then you will not be using some else's files.

 

What is 1/4th of a second speedup? Typically 100% improvement in speed...

 

Bobby

Link to comment
Share on other sites

However, if you create your OWN cache directory and use that path then you will not be using some else's files.
So basically, to be sure, the person should modify the code to ensure that the tmp is pointing to the right folder. There are many servers which are set up this way, since many people are not aware of this issue when setting up the server.....

 

What is 1/4th of a second speedup? Typically 100% improvement in speed...
I doubt if it would be a 1/4 sec saving, and in percentages, yes it can be 100% or something of this nature, but working in percentages is very miss leading. This is more dependant on server load then anything else.

 

I am not saying you are wrong, but rather I wanted to point out a difficulty when using the cashe feature. There are many ways which could speed up tyhe site without having to turn on the cashe feature, and until the cashe is safe for all servers, independant of the settings, I will not use it, nor recomend it to anyone to do so....

 

 

cheers,

 

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

So basically, to be sure, the person should modify the code to ensure that the tmp is pointing to the right folder.  There are many servers which are set up this way, since many people are not aware of this issue when setting up the server.....

Not modify the code...modify the settings located in the admin control panel under Configuration -> Cache -> Cache Directory

 

Step #1 - Create you own cache directory outside your webroot

Step #2 - Give the server write permissions to the folder

Step #3 - Modify the cache directory setting to the folder newly created

 

This will ensure complete privacy and separation from other stores that may be installed on the shared server.

I am not saying you are wrong, but rather I wanted to point out a difficulty when using the cashe feature.  There are many ways which could speed up tyhe site without having to turn on the cashe feature, and until the cashe is safe for all servers, independant of the settings, I will not use it, nor recomend it to anyone to do so....

cheers,

 

Peter M.

I don't find it difficult to use once you set it up properly. I know there are hundreds of ways to speed up an osC store but this one is the most basic and has the most significant speed improvement.

 

The cache feature is safe for all servers. However, the default settings are not. If you follow the steps above it is safer than a triple protected admin directory (as the cache directory is OUTSIDE the web root).

 

Bobby

Link to comment
Share on other sites

Bobby,

 

Both of us understand the steps required here. But the general lay person most likely will not. I understand cashe can speed things up, but until the core code base is switched, I wil not recommend it, unless the site is very slow in loading.

 

Tipically, this is not a huge issue with 90% of the sites out there, rather optimizing the images for size, and other things I would recommend first.

 

I have been down this road before with others, and usually end up having to set it up myself. Now I just tell them not to use it unless they have gone through the other ways first....

 

cheers,

 

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

Thanks all.

 

Well as i run a pretty trafficed site and because i own two dedicated servers (big ones) for my 2 stores i guess for me this is something to do straight away then.

 

I have full control over anything on my servers, so no cross linking can occur.

 

Thanks again! :thumbsup:

Link to comment
Share on other sites

I guess we'll have to agree to disagree on the issue of to cache or not. I am rather biased as most of my contributions are based on caching data...so of course I'm partial to the stock osC caching of categories, manufacturers, and also_purchased which happen to be some of the most intensive MySQL operations on the entire store.

 

It's safe to use on a shared or dedicated server if setup properly. The issue is not whether it's safe but does someone have the time to tell the beginners how to properly setup the directory.

 

Bobby

Link to comment
Share on other sites

Yeah, you are right.

I now know the structure and the biggest part of the system by head, since i have been building the darn shop several times and alo have a trial shop where i always first test anything before implementing it in my live one.

 

If you are a starter, you simply don't know anything yet and thus some parts are pretty difficult to set up if you are a NOOB and non programmer as i am.

 

 

Just one question out of interest though.

 

What happens when you have switched the cache off?

 

Does it then outomatically "cache" everything in the mysql database or is everything created on the fly or something??

Link to comment
Share on other sites

Just wondering what your thoughts are on giving the cache folder a unique name and using .htaccess to prevent viewing of the contents via a browser (and leaving the cache folder under the catalog folder). Also, what kind of information might someone be able to see if they had accesss to your cache files that you wouldn't want them to see? Why would it be a security risk if someone could see them?

Link to comment
Share on other sites

Anything less than having the cache folder OUTSIDE the web root is unacceptable. Why? Because by the nature of a cache directory the web server needs to write to it...meaning it has to have read / write permissions. Guess what? Since the web server can read/write to the cache directory so can anyone else on the internet with a web browser. You can add .htaccess or whatever but that is a bandaide on an artery.

 

The ONLY answer is to put it outside your webroot where it's only vulnerable from inside the server.

 

Bobby

Link to comment
Share on other sites

Anything less than having the cache folder OUTSIDE the web root is unacceptable.  Why?  Because by the nature of a cache directory the web server needs to write to it...meaning it has to have read / write permissions.  Guess what?  Since the web server can read/write to the cache directory so can anyone else on the internet with a web browser.  You can add .htaccess or whatever but that is a bandaide on an artery.

 

The ONLY answer is to put it outside your webroot where it's only vulnerable from inside the server.

 

Bobby

Do you still set permissions at 777? Will it work on any other setting?

Link to comment
Share on other sites

As long as the webserver can read/write to the directory it'll work just fine. I don't want you to get caught up in a certain CHMOD since servers run differently. For example, if your host has PHP running in CGI mode or PHPSuExec it could running as your username in which case 700 will work just fine. However, most run as an Apache module and need 770 permissions.

 

Bobby

Link to comment
Share on other sites

OK sort off the topic, but now I have a folder outside the webroot for page and SEO cache, would I be better (for performance) to change sessions to go in there instead of storing them in the database?

 

I store them in the dbase from habbit of shared servers, but thinking about this post, seems like off root folder for the account would avoid any crossing of data also....

 

So I guess the real question is mysql/cache folder - what is faster and less load?

 

C-

osC Contributions I have published.

 

Note: Some I only provided minor changes, updates or additions!

Link to comment
Share on other sites

Bobby sorry don't agree with you on that one. Its not that big of a gain. No way a 100% improvement.

 

To show an example with some numbers. Note I am not using any compiling accelerator like PHP Accelerator or e-Accelerator or MMCache or whatever and all query caching has been turned off. Any of which will throw off the numbers and make the difference even more insignificant.

 

Index page with cache off: 0.10081s page parse time with 0.01391s query parse time.

 

Index page with cache on: 0.09033s page parse time with 0.01047s query parse time.

 

Index page WITHOUT manufacturer and category boxes: 0.09406s page parse time with 0.01045s query parse time.

 

Based on my data that its only a 0.01s (11%) improvement in parse times. Although yes its still an improvement, just not a significant one. Its such a small improvement (especially when cached and compiled) that I don't use it. And plus...what's the typical OS file access time for opening and reading 2 include files??

I ♥ PHP/MYSQL/CSS

Link to comment
Share on other sites

Bobby sorry don't agree with you on that one.  Its not that big of a gain.  No way a 100% improvement.

 

To show an example with some numbers.  Note I am not using any compiling accelerator like PHP Accelerator or e-Accelerator or MMCache or whatever and all query caching has been turned off.  Any of which will throw off the numbers and make the difference even more insignificant.

 

Index page with cache off:  0.10081s page parse time with 0.01391s query parse time.

 

Index page with cache on:  0.09033s page parse time with 0.01047s query parse time.

 

Index page WITHOUT manufacturer and category boxes:  0.09406s page parse time with 0.01045s query parse time.

 

Based on my data that its only a 0.01s (11%) improvement in parse times.  Although yes its still an improvement, just not a significant one.  Its such a small improvement (especially when cached and compiled) that I don't use it.  And plus...what's the typical OS file access time for opening and reading 2 include files??

 

AXM,

 

I might be talking out of place here, but were your numbers gathered from a vanilla OSC? I ask because although the change was not signifigant there, wouldn't more products change these numbers alot?

 

Chris

osC Contributions I have published.

 

Note: Some I only provided minor changes, updates or additions!

Link to comment
Share on other sites

Anything less than having the cache folder OUTSIDE the web root is unacceptable.  Why?  Because by the nature of a cache directory the web server needs to write to it...meaning it has to have read / write permissions.  Guess what?  Since the web server can read/write to the cache directory so can anyone else on the internet with a web browser.  You can add .htaccess or whatever but that is a bandaide on an artery.

 

The ONLY answer is to put it outside your webroot where it's only vulnerable from inside the server.

 

Bobby

 

 

I put the cache on a separate ramdisk outside the server.

Treasurer MFC

Link to comment
Share on other sites

Actually its on a heavily modified version of OSC. The manufacturer and category box queries were not touched.

 

There is 18 primary categories with a total of 286 categories over 3 levels.

 

Okay I had the chance to do an examination on a deeper category listing page. So 18 main categories, 1 category of which expand with 6 subcategories, and 1 subcategory of which expanded with 10 sub-subcategories.

 

Listing with cache off: 0.23168s page parse time with 0.11740s query parse time.

 

Listing with cache on: 0.20633s page parse time with 0.10511s query parse time.

 

Listing WITHOUT manufacturer and categories box: 0.20473s page parse time with 0.10224s query parse time.

 

So with the 0.025s increase is a significant increase. Not huge but it makes a difference on server load under high traffic conditions. If the categories queries were cached by mysql's query cache it would only be a 0.015 difference though.

I ♥ PHP/MYSQL/CSS

Link to comment
Share on other sites

As long as the webserver can read/write to the directory it'll work just fine.  I don't want you to get caught up in a certain CHMOD since servers run differently.  For example, if your host has PHP running in CGI mode or PHPSuExec it could running as your username in which case 700 will work just fine.  However, most run as an Apache module and need 770 permissions.

 

Bobby

One more question.

 

When I check under cPanel, I see that it suggests a setting of 755:

 

"If this directory contains information needed by a PHP/FrontPage page, check the permissions are set to 755. Otherwise, set the permissions to 700"

 

If I use 755, I get this in the admin panel under Tools-->Cache Contirol:

"Error: Cache directory is not writeable."

 

I assume that the error message comes up because I am using a browser to access the file, and that it will still work if I set Use Cache to True because the server can write to it under a 755 setting. Right?

Link to comment
Share on other sites

OK sort off the topic, but  now I have a folder outside the webroot for page and SEO cache, would I be better (for performance) to change sessions to go in there instead of storing them in the database?

 

I store them in the dbase from habbit of shared servers, but thinking about this post, seems like off root folder for the account would avoid any crossing of data also....

 

So I guess the real question is mysql/cache folder - what is faster and less load?

 

C-

It depends on how many records are stored in the sessions table...

 

Let me explain: the sessions table does not have a key or index so when it queries for a particular session (on each page) it must scan the ENTIRE table to find the match. Now, let's say it is an active shop and there are a few thousand records in the sessions table. It will do a full table scan on each page to find the right session.

 

So, if you are a high volume store then it would be best to create the folder outside the web root and store the sessions there. However, if you are a low volume store then store the in the table.

Bobby sorry don't agree with you on that one.  Its not that big of a gain.  No way a 100% improvement.

...

Was those numbers from a stock install? Something tells me that if you add a few hundred (or thousand) products and/or categories then the improvement may exceed a 100% improvement.

AXM,

 

I might be talking out of place here, but were your numbers gathered from a vanilla OSC?  I ask because although the change was not signifigant there, wouldn't more products change these numbers alot?

 

Chris

I'll bet the farm it wasn't from store with more than 100 categories, products, or orders.

I put the cache on a separate ramdisk outside the server.

Of course, that is the recommended way of setting up a cache folder...but imagine trying to explain how to setup a RAM disk to someone that doesn't understand the concept of cached data to begin with :)

 

Bobby

Link to comment
Share on other sites

Hi

 

Glad someone bothered to come up with numbers. The cashing system is fine to use, and will increase the server processing times. Do not let this confuse people on the page serving time through.

 

Just because a page parses at a specific time, does not mean that the server will send it out directly after it has been parsed. It is still put into the pipeline and sent to the requester at a predetermined rate. This rate varies on many things, and is independant of how fast the hardware can process the php page.

 

So By turning it on, if you have a dedicated server, and heavy traffic (10's of thousands of hits daily ), then the cashe will help make a difference in how fast the page gets to the requester from the server....

 

Just a few thoughts and things to put forward which are relevant as well....

 

cheers,

 

Peter M.

Peter McGrath

-----------------------------

See my Profile (click here) for more information and to contact me for professional osCommerce support that includes SEO development, custom development and security implementation

Link to comment
Share on other sites

Glad someone bothered to come up with numbers.  The cashing system is fine to use, and will increase the server processing times.  Do not let this confuse people on the page serving time through.

Peter, you know those numbers mean very little as it is most likely from a stock store with the stock number of categories / products / orders.

 

The cache system is not only for the categories but also extends to the manufacturers box and also_purchased products module. The also purchased is a killer query and will grind even a dedicated dual CPU server to a halt with more than a few hundred cats / orders / products. So, the use is not limited to the category box...

 

As an example, here is a thread about a relatively large store and their issue with NOT caching the also_purcahesd module: How to debug a nastry query problem

 

Notice, he had a dual 64-bit AMD CPU server for his store and it was taking more than 30-60 seconds to generate the module.

Just a few thoughts and things to put forward which are relevant as well....

The factors which are relevant are: traffic volume of the store, hardware specs of the server, how many accounts are on the server, number of products, number of categories, and number of orders.

 

If you have a store that is high volume or has a significant number of products, categories, or orders it is imperative that you enable the cache system.

 

Bobby

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...