Page 2 of 3

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Fri Oct 10, 2014 6:55 am
by Cue4cheap
Same issue with my multi-store with this error in the error log:
PHP Fatal error: Class 'PageCache' not found in /store/index.php on line 13


Mike

Nope that wasn't it. I guess that was written because I didn't have the file uploaded until after I adjusted the index file. So, so far no errors, just a blank page for every domain of the multistore.

At this point it would be helpful if someone else using multistore could test this and say what their results are.

Mike

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Fri Oct 10, 2014 10:57 am
by gtoc
With a clear cache and first load of a page i'm getting the comment on the page source. Is this correct or should only be on the second cached visit?

Oh and a spelling correction - 'url' in the page source comment is misspelled 'uri'

Otherwise after a couple days on this everything has been great with a single store on 1.5.5.1 and multi currencies.

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Fri Oct 10, 2014 9:17 pm
by budgetneon
gtoc wrote:With a clear cache and first load of a page i'm getting the comment on the page source. Is this correct or should only be on the second cached visit?
Just means someone else visited the page before you did. The "first view" every 4 hours (with the default settings) will create the cached file, then everyone for 4 hours after will get the cached paged (assuming they aren't logged in, nothing in their cart, etc). Or it could mean your browser pulls the data again when you do "view source", I believe some do, and others use the already fetched content.
Oh and a spelling correction - 'url' in the page source comment is misspelled 'uri'
Long story, but a url is a type of uri. Technically, since I have the hostname separated out, it's neither of them :)
Otherwise after a couple days on this everything has been great with a single store on 1.5.5.1 and multi currencies.
Good to hear, thanks.

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Fri Oct 10, 2014 9:38 pm
by budgetneon
Cue4cheap wrote:Nope that wasn't it. I guess that was written because I didn't have the file uploaded until after I adjusted the index file. So, so far no errors, just a blank page for every domain of the multistore.
Did you check your webservers' error log file, or just the opencart error log?

Also, did you "view source" on the blank page to see what's there? For example, both a truly "empty page" and '<html><head></head><body></body></html>' look like a blank page.

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Fri Oct 10, 2014 11:23 pm
by budgetneon
I did just discover an issue. The page cache doesn't support using the 'gzip output compression' option within opencart, so that setting (System->Settings->Edit->Server->Output Compression Level) has to be set to 0. If it's set to anything other than zero, the page cache outputs the compressed data, but without the required HTTP headers for the browser to understand what's being sent, and you get garbage looking characters in the browser.

It does work fine with that setting at 0, and apache's mod_deflate turned on, which is better idea anyway.

That said, I'll note it as a bug.

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Sat Oct 11, 2014 5:42 am
by Cue4cheap
budgetneon wrote:
Cue4cheap wrote:Nope that wasn't it. I guess that was written because I didn't have the file uploaded until after I adjusted the index file. So, so far no errors, just a blank page for every domain of the multistore.
Did you check your webservers' error log file, or just the opencart error log?

Also, did you "view source" on the blank page to see what's there? For example, both a truly "empty page" and '<html><head></head><body></body></html>' look like a blank page.
All error logs empty except for that initial error that I caused by not having things set up right.

The page is 100% empty. View source shows one empty line.

I tried to turn the compression level to 0 as an attempt from what you wrote but nada change.

Mike

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Sat Oct 11, 2014 5:59 am
by budgetneon
I tried to turn the compression level to 0 as an attempt from what you wrote but nada change.
If it was at something other than 0, that could be it. You would have had to delete the existing cache files as well, assuming it was caching an empty file.

Other possibilities:
- you're running a version of php that's lower than 5.4. I made some changes where it works with 5.3, but not well.
- you're running on windows, and don't have the latest copy of the pagecache.php code. The earlier revisions tried to create files with the ':' character in them in some cases, which windows can't cope with.
- the user that your web server is running as (on debian, it's usually www-data) doesn't have permissions to write to the pagecache directory.
- you're running some extension that changes php output buffering in a significant way.

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Sat Oct 11, 2014 6:58 am
by Cue4cheap
budgetneon wrote:
I tried to turn the compression level to 0 as an attempt from what you wrote but nada change.
If it was at something other than 0, that could be it. You would have had to delete the existing cache files as well, assuming it was caching an empty file.

Other possibilities:
- you're running a version of php that's lower than 5.4. I made some changes where it works with 5.3, but not well.
- you're running on windows, and don't have the latest copy of the pagecache.php code. The earlier revisions tried to create files with the ':' character in them in some cases, which windows can't cope with.
- the user that your web server is running as (on debian, it's usually www-data) doesn't have permissions to write to the pagecache directory.
- you're running some extension that changes php output buffering in a significant way.
I'll put this on hold as I put it to 0, deleted the pagecache folder and it does get recreated with files under it. And I can look into the files and see your line of: <!--cache host ... etc. but I still get a blank screen.

Thank you for your attempts and contrib.
Mike

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Sun Oct 12, 2014 12:48 am
by Cue4cheap
I was using fast-cgi with php 5.3 and it wasn't working but I am now using it with 5.4 and it looks like your contib is working.....

Mike

Re: [BETA RELEASED] Page Cache for Opencart 1.5.X

Posted: Sun Oct 12, 2014 10:44 pm
by budgetneon
Cue4cheap wrote:I was using fast-cgi with php 5.3 and it wasn't working but I am now using it with 5.4 and it looks like your contib is working.....
Mike
Good news, thanks. I left an open issue on github regarding fast-cgi with PHP 5.3 or lower.

Added Admin Panel and Installer

Posted: Sun Oct 12, 2014 10:49 pm
by budgetneon
Just added two features

1) Buttons that make the changes to index.php for you, so no manual editing unless your webserver user lacks permissions to modify the index.php file.

Note: If you installed a previous version of this pagecache, remove the changes you made to index.php before installing this latest version. If you don't, you won't be able to use the "Enable/Disable" buttons in the admin panel.

2) An admin panel with stats, buttons to clear the whole cache or just expired entries, etc.

Available here: https://github.com/budgetneon/pagecache

Here's a screenshot of the admin panel:

Image

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Tue Oct 14, 2014 11:58 am
by gtoc
Worked great on test site but my live servers have litespeed. Any chance this could be made to work with LS?

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Tue Oct 14, 2014 12:58 pm
by budgetneon
gtoc wrote:Worked great on test site but my live servers have litespeed. Any chance this could be made to work with LS?
I've not used litespeed, but I just looked at their docs.

Does this mean you're using their "PHP LSAPI" to run php? It seems to have lots of different modes, so I would probably need the gory details of exactly how you're set up (which SAPI, configured how, PHP version, etc )to try and see why it's not working out of the box.

Also, if you could try it and note any errors, that would be helpful.

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Tue Oct 14, 2014 5:30 pm
by gtoc
New to all this so I don't know the technical jargon but they said their server level PHP handler is LSPHP.

Your admin says installed with the message -
PHP Version: 5.4.32, Status: supported (PHP 5.4 or greater)
SAPI: litespeed, Status: unsupported (pagecache has not been tested with this SAPI)

Then when browsing site, no cache files are created. No errors also.

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Tue Oct 14, 2014 11:19 pm
by budgetneon
gtoc wrote:New to all this so I don't know the technical jargon but they said their server level PHP handler is LSPHP.

Your admin says installed with the message -
PHP Version: 5.4.32, Status: supported (PHP 5.4 or greater)
SAPI: litespeed, Status: unsupported (pagecache has not been tested with this SAPI)

Then when browsing site, no cache files are created. No errors also.
I think it may be one of these two things...

a) headers_list isn't supported in that SAPI. To test, create a test file, like test.php with this in it:

Code: Select all

<?php
header("X-Test: A test");
foreach (headers_list() as $header) {
    print "header [$header]<br> \n";
}
?>
Then navigate to it with your browser. You should get a page with just this in it: header [X-Test: A test]. Also look for any errors in either the opencart or webserver logs.

==or==

b) We don't have permission to write to the cache directory, or the method we're using to determine the cache directory doesn't work in your setup. To see if you can fix this, find this line within /youropencartdir/system/library/pagecache.com:

Code: Select all

$this->cachefolder=DIR_CACHE. 'pagecache/';
Edit, and change it to the full path of a directory that you're sure can be written to by the user that your webserver is running as, something like

Code: Select all

$this->cachefolder='/var/www/some/long/path/to/a/directory/';
Note that the trailing slash is important.

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Sun Oct 19, 2014 9:17 am
by Cue4cheap
How do you exclude the featured module, that is shown on my home page (the built in module on 1.5.6)?

I tried '#home/featured#' but that didn't do it. Any thoughts?

Thank you,
Mike

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Mon Oct 20, 2014 4:01 am
by budgetneon
Cue4cheap wrote:How do you exclude the featured module, that is shown on my home page (the built in module on 1.5.6)?

I tried '#home/featured#' but that didn't do it. Any thoughts?

Thank you,
Mike
The exclude urls only works if whatever you're trying to exclude is a url. That could be a regular page, or something that loads via ajax. For example, product reviews load via ajax, with a url like this:

Code: Select all

http://yourstore.com/index.php?route=product/product/review&product_id=6748
The $skip_url patterns are matching parts of a url, so if you wanted to block reviews, you could use any of these:
'#product/product/review#'
'#review&product_id#'
'#duct/review#'

Basically, it's just a pattern that matches part of the url.

I don't think that the featured module loads via ajax. Basically, if you do a "view source", and you can see the html for it, it's not loading via ajax...it's part of the page.

That would mean that there's no way to exclude it...the html of the "Featured Module" is within the page being cached.

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Sat Oct 25, 2014 11:10 pm
by budgetneon
New version...1.0.4.

Noteable things that have been changed in the last couple of updates
  • Added support for litespeed's sapi. ( required working around broken http_status_code() in litespeed )
  • Support for wrapping the embedded cache info html comment with <!--[if IE]><![endif]-->. This is helpful if you have an html minifier (like Cloudflare's) stripping out the comment.
  • Made the call to ob_end_flush() optional, and defaulted to off. It seems to create issues in some environments, and the performance benefit was minimal
  • Deal with index.php files that have carriage returns in them better. Was forcing people to do manual installs in some cases.

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Mon Oct 27, 2014 1:56 pm
by gtoc
Working well with litespeed now, support from developer has been fantastic!

Thanks!

Re: [RELEASED] Page Cache for Opencart 1.5.X

Posted: Wed Nov 12, 2014 6:33 am
by Cue4cheap
budgetneon,

Would it be possible to have it just delete the expired cache files? I looked at the admin side and it said it had 1,xxx expired files. Seems like a bit of extra space that just should go away versus staying around if they are expired. (I deleted them without writing down the exact amount of files or the space it was taking).

Thank you,
Mike