2011. december 13., kedd

Lehet, hogy ez a megoldás? #drupal

Page Caching

If you have this setting enabled (/admin/settings/performance - on normal, not aggressive!), you will notice a small little problem: Page Caching serves you the wrong page template! "Wait a minute!", you say, "I created separate page templates!"

Unfortunately, Drupal uses the page url for the cache id (CID). This is not very useful if there are multiple browsers visiting the same page. As a result, the first browser that requests the URL essentially caches that page with it's own template and the rest of the browser are stuck with the wrong template. Frustrating, I know!

Alas, I have created a solution! Granted, this will not work for those who have already set a custom cache include in their settings.php file. That being said, if anyone has any suggestions or would like to help create hooks for caching... please let me know!

Open your settings.php file for your site and add this towards the end of the file (For those whom have Domain Access installed, place this before it):

  $conf['cache_inc'] = './sites/all/modules/browser_theme/cache.inc';

What this does: Simply put it this cache include file replaces Drupal's cache_get and cache_set functions. It detects what browser you are using (Browscap must be installed and enabled!) and prepends the cache id (CID): browser-major-minor-CID.