budgetneon / v2pagecache

Page Cache for OpenCart V2.X
58 stars 26 forks source link

Auto Caching #3

Closed BrettyWhite closed 8 years ago

BrettyWhite commented 8 years ago

Hello,

This isn't a bug but I was wondering if there was a reason that we cant auto-cache using something like a sitemap to preload all of the pages using cron or similar time oriented trigger after an expiration of cached files?

If there wasn't a reason or it wasnt thought of I will personally look into it and contribute what I write.

Thanks

budgetneon commented 8 years ago

It caches the pages as they are accessed, so you could accomplish this by just crawling the page using curl or a similar tool.

BrettyWhite commented 8 years ago

A simple JavaScript crawler worked wonders. Thanks for the suggestion.

BrettyWhite commented 8 years ago

One other thing I noticed was that cached pages do not update the cart information if the person had an item in their cart and viewed a page. I will also look into this, just wanted to make you aware of it. Thanks again for this library.

budgetneon commented 8 years ago

It shouldn't be returning a cached page if you put something in the cart...here's the section of code:

// don't cache if affiliate page, or cart has items in it
    if (!empty($_GET['affiliate']) || !empty($_SESSION['cart']))  {
        $this->oktocache=false;
        return $this->oktocache;
    } 

Basically, the caching, and return of cached pages is off for anyone with an item in the cart.

budgetneon commented 8 years ago

I see the problem now. Right after version 2.0.3.1, opencart changed the way they handle cart data for sessions....it looks like they may have gotten rid of the cart session key.

budgetneon commented 8 years ago

Yeah, doesn't look good....it looks like opencart made it so you can't tell if there are items in the cart unless you query the database, which is a pretty heavyweight thing to do for a page cache.

I will close this issue, since the name of the issue isn't right, and open a new issue.