[MODDB] Cache Guests Pages

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Suggested Hosts
User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

[MODDB] Cache Guests Pages

Post by Kot Matroskin » Wed Feb 13, 2013 12:36 am

Kot Matroskin wrote:The mod has been successfully validated recently. So, this topic will be closed, all support will be provided in corresponded section. Thanks all for testing!

Modification Name: Cache Guests & Bots pages
Author: Kot Matroskin

Modification Description: Content of pages displayed to guests and bots will be stored in file cache, and obtained from the cache on recurrent page visit. Installing this module will significantly decrease server load caused by guests and bots visits, but please note that cache size will be increased proportional to guests activity.

Modification Version: 1.1.1

Features:
  • Pages generation time better in 10-50 times (opened by guests and bots);
  • Cached pages: index.php, viewforum.php, viewtopic.php, portal.php (Board3 Portal related);
  • Easy to apply for almost any other page within phpBB;
  • ETag/If-None-Match headers support (caching on HTTP protocol layer as well);
  • Write-through caching: if anyone modifies topic content, corresponding topic and forums cache files will be removed.
Image

Note: For evaluating real page load time please pay attention on debug timing in the left bottom corner of the page. Debug information on standard place of your page displays time taken on generation of original page, without caching. Pay attention on the screenshot below -- page generation time is displayed in two places.

Screenshot:

Image

Demo URL: http://scooterclub.by/nforum

Modification Download: cache_guests_pages-1.1.1.zip

P.S. Russian language support topic: http://www.phpbbguru.net/community/topic38920.html
Last edited by Kot Matroskin on Tue Mar 12, 2013 9:05 pm, edited 10 times in total.

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: [Beta] Cache Guests Pages

Post by Haravikk » Wed Feb 13, 2013 1:07 pm

Just installed your mod!

Some minor installation issues; first is that it fails to apply changes to portal.php which I don't have on my forum, I'm not sure if it's possible to mark MODX steps as optional? After telling it to continue the other changes installed without issue.

Second, I had to rename the install/ folder in order to run the installer, when it was named install/ I just got an error message telling me to remove or rename the install folder. I've noticed a few mods that do that, not sure what it causes the problem. Renaming it to installs/ allowed it to work fine, but there may be something you can change to make it work correctly? I don't know.


Once that's sorted the mod installs and seems to work extremely well, I'll have to do more testing to see how big a difference it makes for me, but it's up and running with no fuss.

Now, my main aim in testing was to see if it would work with my HTTP caching mod, unfortunately it doesn't quite work as this mod overrides HTTP headers before displaying a cached page, and unfortunately the only way to cache headers would be to use the headers_list() function which is PHP 5 only. I may have to investigate adding an extra tweak to my mod that lets it ensure the correct headers (for it) are set.

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Wed Feb 13, 2013 1:29 pm

Haravikk wrote:Some minor installation issues; first is that it fails to apply changes to portal.php which I don't have on my forum, I'm not sure if it's possible to mark MODX steps as optional? After telling it to continue the other changes installed without issue.
Reasonable note. Firstly I wanted to provide caching of portal.php as additional change within the mod... But then dismiss it. I'll try to investigate MODX file format to find something like IF-FILE-EXISTS or OPTIONAL. Or will do it as addon for the mod.
Haravikk wrote:Second, I had to rename the install/ folder in order to run the installer, when it was named install/ I just got an error message telling me to remove or rename the install folder. I've noticed a few mods that do that, not sure what it causes the problem. Renaming it to installs/ allowed it to work fine, but there may be something you can change to make it work correctly? I don't know.
Really, I don't think that it is strong requirement to move UMIL installation file to install/ or installs/ folder. I ever could call it as cgp_unil.php, and place at the root of a forum.

But! This file is redundant, and should be removed after first call. Right? Right. Also I can't guarantee that my mod will work correct without launching of this file. So, taking it into account, I'd prefer to place it into install/ folder to remind admin both for calling it and for removing it after the installation. I thought it is common practice in phpBB.
Haravikk wrote:Now, my main aim in testing was to see if it would work with my HTTP caching mod, unfortunately it doesn't quite work as this mod overrides HTTP headers before displaying a cached page, and unfortunately the only way to cache headers would be to use the headers_list() function which is PHP 5 only. I may have to investigate adding an extra tweak to my mod that lets it ensure the correct headers (for it) are set.
I think we should work together with it. Use some common mechanism for generating headers, or something else.

I my case I used custom header generation just to return response much closer to original. phpBB generates this response within header page_header() function. It is hard to reuse it in my case. So that is why I've used custom http-headers generation within my mod.

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: [Beta] Cache Guests Pages

Post by Haravikk » Wed Feb 13, 2013 2:02 pm

Kot Matroskin wrote:But! This file is redundant, and should be removed after first call. Right? Right. Also I can't guarantee that my mod will work correct without launching of this file. So, taking it into account, I'd prefer to place it into install/ folder to remind admin both for calling it and for removing it after the installation. I thought it is common practice in phpBB.
Actually, my own HTTP guest caching mod uses a UMIL installer under install/index.php; I took a quick look and I'm not sure what I'm doing differently though, but it works without having to rename the folder. I've got some other work to do today but if I get another chance I'll look and see if I can figure out why mine works and yours doesn't.
Kot Matroskin wrote:I my case I used custom header generation just to return response much closer to original. phpBB generates this response within header page_header() function. It is hard to reuse it in my case. So that is why I've used custom http-headers generation within my mod.
You're definitely right to; one thing I'm thinking of doing is moving my replacement headers into a function inside my main class. In this case to add support for my mod should be a case of doing something like:

Code: Select all

// Somewhere after header('Pragma: no-cache');

global $mod_http_guest_cache;
if (isset($mod_http_guest_cache))
{
    $mod_http_guest_cache->set_headers();
}
Anyway, we can bounce discussion of this back over to my thread if you prefer to keep this one tidy, but I think my next update to my HTTP guest cache will include the set_headers() function which will hopefully make support a bit easier, as the above code wouldn't affect anyone that doesn't have my mod installed.

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: [Beta] Cache Guests Pages

Post by Haravikk » Wed Feb 13, 2013 7:57 pm

Heh, I think the installer issue is a fairly simple one; I believe you just need to add define('IN_INSTALL', true); somewhere near the top of install.php, this way you can use the install/ directory without board owners getting the error when they try to run it.


Oh, one question about your mod, but you say in your notes that it is strongly recommended to disable a guest's ability to quick-reply, however I don't think guests can use quick-reply anyway? The check for it in viewtopic.php includes $user->data['is_registered']. It may be worth clarifying that the conflict would be with any mods that enable guests to use quick-replies, because otherwise I'm not sure this issue should come up.

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Wed Feb 13, 2013 8:18 pm

Haravikk wrote:Oh, one question about your mod, but you say in your notes that it is strongly recommended to disable a guest's ability to quick-reply, however I don't think guests can use quick-reply anyway? The check for it in viewtopic.php includes $user->data['is_registered']. It may be worth clarifying that the conflict would be with any mods that enable guests to use quick-replies, because otherwise I'm not sure this issue should come up.
Thank you for that valuable note. Really, I used Prime Quick Reply mod on my forum, and Quick Reply form was allowed for any quest by default (not sure that it is Prime Quick Reply original behavior, may be my own oldest changes).

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Fri Feb 15, 2013 10:21 am

Haravikk wrote:Heh, I think the installer issue is a fairly simple one; I believe you just need to add define('IN_INSTALL', true); somewhere near the top of install.php, this way you can use the install/ directory without board owners getting the error when they try to run it.
Nothing happens. Btw, install.php from your installation also raises warning message.

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Fri Feb 15, 2013 10:40 am

Version 0.3.0 has been released, find first post updated.

Changes:
  • Added cache size information to admin page
  • Added compatibility with HTTP Guests cache mod

leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [Beta] Cache Guests Pages

Post by leschek » Fri Feb 15, 2013 12:15 pm

Haravikk wrote:Just installed your mod!

Some minor installation issues; first is that it fails to apply changes to portal.php which I don't have on my forum, I'm not sure if it's possible to mark MODX steps as optional? After telling it to continue the other changes installed without issue.

Second, I had to rename the install/ folder in order to run the installer, when it was named install/ I just got an error message telling me to remove or rename the install folder.
Tried to install 0.3.0 with AutoMOD and had the very same issues as Haravikk. After renaming the install folder I was able to finish installation of the MOD.

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Fri Feb 15, 2013 12:25 pm

Why do you need to remove this folder before completing the installation?? This folder is important for mod's configuration, you have to launch script inside for completing the installation. After that feel free to remove this folder from your server. That is why it called "install" -- phpBB remind you about of necessity for removing this folder.

leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [Beta] Cache Guests Pages

Post by leschek » Fri Feb 15, 2013 12:35 pm

Yes, I know. But it doesn't allow me to run install until I renamed the folder. And only message I got was to remove the file.

This is what happened during installation:
1. I installed the file changes (had to force AutoMOD to do it because of the portal.php file)
2. then I should run the file install/index.php (there was link in AutoMOD on usual place), but it showed me message about deleting/renaming the install folder. I wasn't able to run it. It always showed the message.
3. After renaming the install folder I was able to finish installation.

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Fri Feb 15, 2013 1:00 pm

leschek wrote:2. then I should run the file install/index.php (there was link in AutoMOD on usual place), but it showed me message about deleting/renaming the install folder. I wasn't able to run it. It always showed the message.
You ever can't go to proposed link? Just getting the error instead of opening UMIL installation page?

leschek
Registered User
Posts: 791
Joined: Tue Jul 18, 2006 12:49 pm
Contact:

Re: [Beta] Cache Guests Pages

Post by leschek » Fri Feb 15, 2013 1:25 pm

Yes, exactly. I believe that Haravikk had the same problem.
Haravikk wrote: I had to rename the install/ folder in order to run the installer...

User avatar
Kot Matroskin
Registered User
Posts: 126
Joined: Sat May 29, 2010 9:44 am
Location: Minsk, Belarus
Name: Vitaly Filatenko
Contact:

Re: [Beta] Cache Guests Pages

Post by Kot Matroskin » Fri Feb 15, 2013 1:35 pm

Ok, I've did "hot cachges" on install, the issue should be disappeared.

That is very strange why I didn't encountered with this error...

Haravikk
Registered User
Posts: 261
Joined: Sat Nov 02, 2002 4:42 pm

Re: [Beta] Cache Guests Pages

Post by Haravikk » Fri Feb 15, 2013 4:29 pm

Oh, I've just noticed a minor issue with my mod that may also affect yours; not a conflict but rather that if either (or both) of our mods are triggered while generating a guest page which performs a cron-job, then the call to cron.php ends up embedded in the cached page, meaning every time that the cached copy is opened an unnecessary call to cron.php is triggered by the guest user's browser.

The fix is fairly simple; basically just a check in page_footer() of includes/functions.php to see if $run_cronis set to true, and if so to change it to false if the resulting page is going to be cached, this should stop the cron-job generating code from triggering.

I think if you add a similar check for your mod then the two shouldn't conflict.
Last edited by Haravikk on Sat Feb 16, 2013 10:32 am, edited 1 time in total.

Locked

Return to “[3.0.x] MODs in Development”