Welcome Guest, Not a member yet? Register   Sign In
Codeigniter caching
#1

[eluser]jplanet[/eluser]
I have a large e-commerce site done in Codeigniter, and I'm wondering if anyone here has experience with its caching feature...I am wondering if there are any issues or drawbacks to this feature that I should be aware of before going live with it...Especially as far as SEO issues are concerned...
#2

[eluser]gon[/eluser]
I had some requirements that CI cache wouldn't solve, so I started using Zend_Cache, the cache library from Zend Framework.

Check the Zend user manual for details on using this lib.

Integrating it with CI is quite easy. You can just instantiate a cache object, or use this Zend component loader.

This code is not mine, but I don't remember where I took it. Could be on the WIKI.

Code:
<?php if (!defined('BASEPATH')) {exit('No direct script access allowed');}

/**
* Zend Framework Loader
*
* Put the 'Zend' folder (unpacked from the Zend Framework package, under 'Library')
* in CI installation's 'application/libraries' folder
* You can put it elsewhere but remember to alter the script accordingly
*
* Usage:
*   1) $this->load->library('zend', 'Zend/Package/Name');
*   or
*   2) $this->load->library('zend');
*      then $this->zend->load('Zend/Package/Name');
*
* * the second usage is useful for autoloading the Zend Framework library
* * Zend/Package/Name does not need the '.php' at the end
*/
class CI_Zend
{
    /**
     * Constructor
     *
     * @param    string $class class name
     */
    function __construct($class = NULL)
    {        

        if ($class)
        {
            require_once (string) $class . EXT;
            log_message('debug', "Zend Class $class Loaded");
        }
        else
        {
            log_message('debug', "Zend Class Initialized");
        }
    }

    /**
     * Zend Class Loader
     *
     * @param    string $class class name
     */
    function load($class)
    {
        require_once (string) $class . EXT;
        log_message('debug', "Zend Class $class Loaded");
    }
}

?>
#3

[eluser]ehicks727[/eluser]
[quote author="jplanet" date="1219100850"]I have a large e-commerce site done in Codeigniter, and I'm wondering if anyone here has experience with its caching feature...I am wondering if there are any issues or drawbacks to this feature that I should be aware of before going live with it...Especially as far as SEO issues are concerned...[/quote]

Are you having a performance problem right now? What is your reason for implementing caching?

What SEO issues do you think this would cause? Do you have a specific problem that you think may happen?
#4

[eluser]jplanet[/eluser]
[quote author="ehicks727" date="1219532604"]
Are you having a performance problem right now? What is your reason for implementing caching?[/quote]

The site is on Bluehost, which has a rather draconian policy of taking your site offline if it goes above their very limited CPU usage restrictions. So, the site was beautifully coded and running very fast, but the site is fairly high volume, with about 1000 visitors per day, so caching some of the more query-intensive pages helps prevent the site from being taken offline.

[quote author="ehicks727" date="1219532604"]
What SEO issues do you think this would cause? Do you have a specific problem that you think may happen?[/quote]

I don't think there would be any, but my client's business relies 100% on SEO standing, and has made a big investment in that area. So, if let's say for instance that caching meant that CI sent a redirect header of some sort before rendering the page, that page could fall off of the search engine result pages -- I'm sure that this isn't the case, but it never hurts to be sure...
#5

[eluser]ehicks727[/eluser]
[quote author="jplanet" date="1219534041"]The site is on Bluehost, which has a rather draconian policy of taking your site offline if it goes above their very limited CPU usage restrictions. So, the site was beautifully coded and running very fast, but the site is fairly high volume, with about 1000 visitors per day, so caching some of the more query-intensive pages helps prevent the site from being taken offline.[/quote]

Hmm.. the obvious solution to that is to switch hosts! If you threaten them that you're leaving because of that reason, maybe they'll work something out for you that if you go over your bandwidth, they'll just charge you a per GB overage (kind of like your cell phone minutes), instead of just cutting your site off. That does seem very draconian.

I use CaroNet and they don't pull crap like that. Of course, I also purchase more bandwidth than what I use and I monitor it to see if I'm getting close.

Regardless, good use for caching, I would think. Might be worth a shot.



[quote author="jplanet" date="1219534041"]I don't think there would be any, but my client's business relies 100% on SEO standing, and has made a big investment in that area. So, if let's say for instance that caching meant that CI sent a redirect header of some sort before rendering the page, that page could fall off of the search engine result pages -- I'm sure that this isn't the case, but it never hurts to be sure...[/quote]

There are other tools for inspecting client/server 'conversations', but I prefer and use WebScarab (http://www.owasp.org/index.php/Category:...ab_Project). If you use it, grab the self-contained .jar file. You have to install at least a Java runtime to launch it.

What this will do is allow you to see the exact server response codes that your server is sending.

I had an issue like yours, in regards to using the CodeIgniter's redirect() function. I picked it apart using WebScarab, and sure enough, CI sends a legit 301, which is an allowed and acceptable practice, according to Google. Won't hurt your SEO efforts.
#6

[eluser]jplanet[/eluser]
Thanks for checking out CodeIgniter with WebScarab, that confirms what I suspected, which is great news! I had been using Firefox's Live HTTP Headers plugin, but wasn't sure how accurate it was.

My first instinct was to change hosts - I had also threatened to leave, but for $8/month I'm not really putting a dent in anything. I'm sure they just figured that losing a high-maintenance, high-cpu customer would just leave room on that server for someone with a blog that gets five hits each week and never hassles them.

Besides, the good news is that since I've implemented caching -- which was so easy, just a single line of code in each controller function that I wanted to cache -- there have been no CPU issues with Bluehost at all. That was a lot less work than changing hosts, which is a nightmare on a site like this because there are literally transactions every minute, and a site move would lead to an inevitable loss in sales no matter how smoothly it went, if just for the fact that DNS changes propagate in different areas at different times. Then there's the headache with getting a new SSL certificate, which can't be done until the DNS changes take effect, etc...

So, as long as the caching works, which it appears to be doing beautifully, we get to enjoy our dirt-cheap hosting, and customers get a very, very fast website that will keep working even if there's an issue with the database or if other sites on the shared server slow it down...
#7

[eluser]surfgatinho[/eluser]
The problem with using the Codeigniter caching is it caches the whole page (or at least that's what I think)
If you are running an ecommerce app this isn't going to work well with the cart or logged in views
#8

[eluser]jplanet[/eluser]
[quote author="surfgatinho" date="1219624584"]The problem with using the Codeigniter caching is it caches the whole page (or at least that's what I think)
If you are running an ecommerce app this isn't going to work well with the cart or logged in views[/quote]

Ah, good point, now I know why the # of items in cart at the top of the page always said "1". I think I can resolve that by putting that item of the page in a little iframe...The cart is stored in the database and referred to throughout shopping and checkout with the CI session id, so that is holding up nicely even with the caching...
#9

[eluser]surfgatinho[/eluser]
Ye, I solved it myself using ajax:
http://ellislab.com/forums/viewthread/89058/




Theme © iAndrew 2016 - Forum software by © MyBB