This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Commentics making the page really slow?
#1
Exclamation 

Dear Commentics,

Thank you for your great code, however it's drastically slowing down my pages. Any idea what this could be?

Kind Regards,

KKoopman
Reply
#2

Hello Klaas, Steven,


is it possible that this causes the slow page load??

[14-Feb-2012 15:15:06] PHP Warning: file_get_contents(http://www.mysite.com/vakantie-frankrijk/ain/) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable
in /home/myserver/domains/mysite.com/public_html/miniblog/comments/includes/functions/page.php on line 73

If so can we get around it.

Reply
#3

Hello Steven,

Mailed the ISP on the report error.

Also I checked the fopen like this:

<?
if( ini_get('allow_url_fopen') ) {
echo hello;
}
else {
echo damn the f-open does not work;}
?>

But it seems to work since the output is ... hello.

Found some info on this topic in which is referred to msql server on overload, others talking about clearing server cache and usage of curl.
Checking of the page.php file learns that curl is being used.

Also I have on this server several websites with databases of 20 to 50 mb each outputting 20-50K pages each and they have no trouble. So my guess is that there is something wrong at server level and file get contents / allow url fopen



Reply
#4

Tested the server / url again with this:

<?php
$result=file_get_contents("http://www.mysite.com/vakantie-frankrijk/ain/");
if ($result === false)
{
echo false;
} else {
echo true;
}
?>


The return was one time false and one time good.
Reply
#5

Been looking at server logs.

If I enable commentics I find apache errors.
As soon as I remove commentics the error logs stay clean.

But the comment and form are shown and also the correct page_id and reference_id are used by the system. So it works, but very slow and with commentics log errors and apache errors.

this is my php include for commentics:


<?php
$page_id = "cmtx_title";
$reference = "cmtx_url";
$path_to_comments_folder = "../miniblog/comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
?>


Apache error log:

[Wed Feb 15 11:03:12 2012] [error] mod_hostinglimits:Error on LVE enter: LVE(570) HANDLER(application/x-httpd-php) HOSTNAME(www.mysite.nl) URL(/vakantie-frankrijk/regio.php) TID(13233) errno (7)
[Wed Feb 15 11:03:12 2012] [error] [client 222.253.0.23] File does not exist: /home/myserver/domains/mysite.nl/public_html/503.shtml
[Wed Feb 15 11:03:14 2012] [error] [client 111.72.129.127] File does not exist: /home/myserver/domains/mysite.nl/public_html/\\"http:, referer: http://www.mysite.nl/vakantie-frankrijk/ain/
[Wed Feb 15 11:03:14 2012] [error] [client 111.72.129.127] File does not exist: /home/myserver/domains/mysite.nl/public_html/404.shtml, referer: http://www.mysite.nl/vakantie-frankrijk/ain/
[Wed Feb 15 11:03:14 2012] [error] [client 111.72.129.127] File does not exist: /home/myserver/domains/mysite.nl/public_html/\\"http:, referer: http://www.mysite.nl/vakantie-frankrijk/ain/
[Wed Feb 15 11:03:14 2012] [error] [client 111.72.129.127] File does not exist: /home/myserver/domains/mysite.nl/public_html/404.shtml, referer: http://www.mysite.nl/vakantie-frankrijk/ain/

Reply
#6

Steven,

If I change the dynamic integration of urls and especially the $page_id = "cmtx_title"; part to the standard example with 1 and page 1. Everything speeds up. Even if I only make the reference dynamic everything is fast.

This is not what I want.

So I have 2 questions: since the ISP is also looking into it:

1. is my usage of de $page_id and $reference correct ??
2. is this being caused on server level or the page.php file aorund the title function lines 65 - 75
3. can possibly an htaccess file be the cause? seems strange since I tested this through removal of commentics script and zero errors on apache level

<?php
$page_id = "cmtx_title";
$reference = "cmtx_url";
$path_to_comments_folder = "../miniblog/comments/";
define ('IN_COMMENTICS', 'true'); //no need to edit this line
require $path_to_comments_folder . "includes/commentics.php"; //no need to edit this line
?>

Reply
#7

Hello Steven,

ISP answered, fopen is not open. So the data is gathered as we can see through the curl function.

No answer on way this is causing the slowness from their side.


We will experiment with de page and reference id.

Reply
#8

Hi,

Can you try these two solutions:

1.

In comments/includes/functions/page.php, line 83, replace this:
PHP Code:
<?php 
if (preg_match("/<title>(.+)<\/title>/i", $file, $match)) {

With this:
PHP Code:
<?php 
if (preg_match("/<title>(.*?)<\/title>/i", $file, $match)) {

2.

In comments/includes/functions/page.php, lines 83 to 89, replace this:
PHP Code:
<?php 
if (preg_match("/<title>(.+)<\/title>/i", $file, $match)) {
if (
$page_id == "cmtx_title") { $page_id = $match[1]; }
if (
$reference == "cmtx_title") { $reference = $match[1]; }
} else {
if (
$page_id == "cmtx_title") { $page_id = "Title not found"; }
if (
$reference == "cmtx_title") { $reference = "Title not found"; }
}

With this:
PHP Code:
<?php 
$doc
= new DOMDocument();
@
$doc->loadHTML($file);
$nodes = $doc->getElementsByTagName('title');
$title = $nodes->item(0)->nodeValue;
if (
$page_id == "cmtx_title") { $page_id = $title; }
if (
$reference == "cmtx_title") { $reference = $title; }

Have you completed the interview?
Reply
#9

Hello Steven,

Thnx for that code, will try it and post results.

And yes, commentics was getting so slow that it took 20-30 seconds before a page was loaded.

At this moment I am including own php variables to get unique storage format in DB / adminpanel and commentics is fast.


By the way it is a super nice comment system.Big Grin
Reply
#10

Hi,

Okay I'm glad it's working fast for you now. I look forward to your results.

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
22-Feb-2024, 06:58 PM
Last Post by Koksi
22-Nov-2012, 03:19 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)