有没有一种方法来缓存drupal系统页面(例如分类/术语/%,论坛/%,节点)授权用户没有核心黑客?缓存drupal系统页面
0
A
回答
1
对于drupal 6,有http://drupal.org/project/authcache。我不相信drupal 7已经准备好了。
0
你可以在你的自定义模块上启动hook_menu_alter,然后从那里你可以做任何你想要的路径(分类/术语/%)。
检查这些路径的函数回调是什么。例如:
mysql>
select * from menu_router where path like '%taxonomy/term/%';
它说页回调是taxonomy_term_page。你并不需要所有的代码复制到您的自定义功能,所有你需要做的是这样的:
function mymodule_menu_alter(&$items) {
// Route taxonomy/term/% to my custom caching function.
$items['taxonomy/term/%']['page callback'] = 'mymodule_cached_taxonomy_term_page';
}
function mymodule_cached_taxonomy_term_page($term) {
// Retrieve from persistent cache.
$cache = cache_get('taxonomy_term_'. $term);
// If data hasn't expired from cache.
if(!empty($cache->data) && ($cache->created < $cache->expire)) {
return $cache->data;
} else {
// Else rebuild the cache.
$term_page = taxonomy_term_page($term);
cache_set('taxonomy_term_'. $term, $term_page, 'cache_page', strtotime('+30 minute'));
return $term_page;
}
}
如果走这条路,你就会想要与cache_get和cache_set熟悉。你可能也想看看Lullabot的优秀缓存article。
您可以按照相同的方法查找论坛/%,节点以及其他任何您想要的内容。快乐缓存!
相关问题
- 1. Drupal +页面片段缓存
- 2. 如何刷新缓存的Drupal页面?
- 3. 系统/操作系统缓存与应用程序缓存
- 4. 如何限制系统上页面缓存的数量?
- 5. 这个页面缓存系统是否合理?
- 6. 系统缓存vs无缓存
- 7. 缓存页面
- 8. NHibernate系统缓存到期
- 9. 说明Magento缓存系统
- 10. MySQL操作系统缓存
- 11. Drupal |缓存页面中未缓存的JS cookie /跟踪代码算法
- 12. silverlight页面缓存
- 13. 缓存asp.net页面
- 14. 缓存HTML页面
- 15. 非缓存页面
- 16. Node.js页面缓存
- 17. 刮缓存页面
- 18. Codeigniter缓存页面
- 19. 缓存HTML页面
- 20. IE10缓存页面
- 21. 将JSON保存到系统缓存中
- 22. 保存页面缓存
- 23. Drupal模块页面“统计”图
- 24. 网关页面系统
- 25. Drupal刷新页面需求缓存也删除javascript文件
- 26. 什么是Drupal中的外部页面缓存
- 27. 有没有办法告诉Drupal不要缓存特定页面?
- 28. Drupal保存在“管理字段”页面非常缓慢
- 29. 多级页面系统和多级缓存系统(L1,L2,L3)之间的区别
- 30. 如何在我的linux系统中停止磁盘I/O的页面缓存?
我想过这种方式。但是taxonomy_term_page不仅返回html页面代码,还会创建面包屑并添加feed。 它不会在mymodule_cached_taxonomy_term_page中工作。其他回调函数additionaly可以使用drupal_set_title,drupal_add_js,drupal_add_css等。 – 2011-03-11 05:06:18
我知道了,我还看到了taxonomy_term_page代码=(。如果不像上面提到的那样缓存taxonomy_term_page的结果,那么如果深入了解该函数,并有选择地将代码复制到自定义函数中,代码如何你需要,然后分别调用feeds功能吗?你试过吗?让我们知道你发现了什么。 – 2011-03-11 05:12:32
是的,我用taxonomy_term_page类似的代码。它工作正常。现在我正在寻找缓存其他核心页面的解决方案(节点,node /%,forum)我不想把所有的drupal核心回调函数都移到我的模块中。) – 2011-03-11 06:11:39