TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Extra fast caching with Mod_Rewrite ?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Milop
Date: 2012-09-26
Time: 10:52

Extra fast caching with Mod_Rewrite ?

I'm just look on wordpress "WP Super Cache" plugin and its feature:

"Mod_Rewrite. The fastest method is by using Apache mod_rewrite (or whatever similar module your web server supports) to serve "supercached" static html files. This completely bypasses PHP and is extremely quick. If your server is hit by a deluge of traffic it is more likely to cope as the requests are "lighter". This does require the Apache mod_rewrite module (which is probably installed if you have custom permalinks) and a modification of your .htaccess file. Visits by anonymous or unknown users will be served this way."

What is does is this code in .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
</IfModule>

Do you think we can implement it somehow with TBS caching ???
By: Skrol29
Date: 2012-09-27
Time: 01:19

Re: Extra fast caching with Mod_Rewrite ?

It seems to me that a cache engine has previously prepared a cached page (probably the Word Press cache engine), and then the Rewrite Mode just make a redirection from the normal page to the cached page.
By: Milop
Date: 2012-09-27
Time: 07:31

Re: Extra fast caching with Mod_Rewrite ?

Yes, that is how it work. But I guess that system also generate new cache file on fly if that one doesn't exist.
Do you think we can implement something like this with TBS and caching plugin ?
By: Skrol29
Date: 2012-09-29
Time: 00:55

Re: Extra fast caching with Mod_Rewrite ?

>Do you think we can implement something like this with TBS and caching plugin ?

Probably yes. But The TBS caching plug-in already have a kind if redirection.