Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
2 posts Page 1 of 1
UPDATE: the complete explanation is now published at Midware Core Concepts » Caching Pages

caching.gif
caching.gif (774.9 KiB) Viewed 1156 times

______________________

Cache is a very nice feature, which serves pregenerated html files, makes pages load lightning fast, does not call any tags and mysql. Basically, serving a static page.

Cache can be enabled/disabled in /couch/config.php
define( 'K_USE_CACHE', 1 );


I'm quoting @KK here below with even more details about caching. It might save a lengthy answer in future. I personally found something new in it.
______________________

Basically Couch employs a very simple kind of caching strategy.
Following is some pseudo-code of the process -

Code: Select all
if( caching is on ){

    if( user is not logged-in AND has explicitly not asked to bypass cache){ // by appending 'nc=1' to the URL the cache can be bypassed
   
        if( the current URL is in cache ){ // a file with the name of the current URL's MD5 hash is searched in cache
       
            if( the cache has not been busted ){ // any 'save' has not been done to *any* page after this file was cached
                return this cached file // execution ends here
            }
           
        }
    }
}

//if we are here, either the user was logged in, or an unlogged user had used 'nc=1' or the current URL was not in cache ..
// process request normally (i.e. parse template and send back whatever was outputted)

output = parse_template() // i.e run all Couch tags to get the final output

if( caching is on ){

    if( <cms:no_cache /> was not found anywhere in the template just parsed ){
        cache_output() // save it as a file named with the MD5 of the current URL
    }
   
}

return output // end of execution


I think that should give you an over-all view of the process.
Wow great explanation! :D
Now i understand how couch's cache work!

Nice job green lantern squad!
As soon as possible!

Touch me up : abada[dot]zulma[at]gmail[dot]com
2 posts Page 1 of 1
cron