Status | ||||
---|---|---|---|---|
|
Warning | |
---|---|
title | DEPRECATEDThe information below is either outdated, or no longer considered best practice at Kalamuna. |
...
The Dynamic Cache module allows you to set a global variable to turn on and off cached page responses if you use it within a hook_boot() implementation. The following hook_boot() sees if anonymous traffic is coming from Google; if it is, it keeps cache disabled. Otherwise, it'll enable caching and use cached responses (or generate one):
FCF w/Dynamic Cache
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function fcf_boot() { if (!$GLOBALS['user']->uid) { global $user; // Determine if Google is the referrer. $host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST); // subdomain.google.com $parts = array_reverse(explode('.', $host)); // (com, google, subdomain) // Make sure we have at least 3 parts to avoid undefined array key notices. while (count($parts) < 3) { $parts[] = ''; } list($tld, $domain, $subdomain) = $parts; if ($domain == "google" ) { // Set a variable (only good for current request) that other // applications can use to determine if this is a FCF instance. $_POST['fcf'] = TRUE; } else { // Enable cache for non-google requests. $GLOBALS['conf']['cache'] = TRUE; } } } |
...
https://www.drupal.org/node/875152: D6-relevant thread, which outlines the approach that was used to create Dynamic Cache.
Review History
Who | When | Status |
---|---|---|
Bob | 20230509 | Deprecated |