You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Drupal10中Drush执行cr显示成功但缓存未实际清理的问题

Drush缓存重建提示成功但未实际生效的排查原因

尽管Drush执行缓存重建命令后提示[success] Cache rebuild complete.,但实际缓存清理并未生效——比如修改模板文件后,执行drush cr看不到模板更新效果,只有通过Drupal后台管理面板清除缓存才能生效。

执行的命令及详细输出:

root@p656470:~# sudo -u www drush cr -vvv
[preflight] Config paths: /www/wwwroot/site.com/vendor/drush/drush/drush.yml
[preflight] Alias paths: /www/wwwroot/site.com/web/drush/sites,/www/wwwroot/site.com/drush/sites
[preflight] Commandfile search paths: /www/wwwroot/site.com/vendor/drush/drush/src
[info] Starting bootstrap to site [0.07 sec, 7.78 MB]
[info] Drush bootstrap phase 2 [0.07 sec, 7.78 MB]
[info] Try to validate bootstrap phase 2 [0.07 sec, 7.78 MB]
[info] Try to validate bootstrap phase 2 [0.07 sec, 7.78 MB]
[info] Try to bootstrap at phase 2 [0.07 sec, 7.78 MB]
[info] Drush bootstrap phase: bootstrapDrupalRoot() [0.07 sec, 7.78 MB]
[info] Change working directory to /www/wwwroot/site.com/web [0.07 sec, 7.78 MB]
[info] Initialized Drupal 10.1.6 root directory at /www/wwwroot/site.com/web [0.08 sec, 7.83 MB]
[info] Try to validate bootstrap phase 2 [0.08 sec, 7.83 MB]
[info] Try to bootstrap at phase 2 [0.08 sec, 8.28 MB]
[info] Drush bootstrap phase: bootstrapDrupalSite() [0.08 sec, 8.28 MB]
[debug] Could not find a Drush config file at sites/default/drush.yml. [0.08 sec, 8.44 MB]
[info] Initialized Drupal site default at sites/default [0.08 sec, 8.44 MB]
[success] Cache rebuild complete. [1.72 sec, 63.8 MB]

以下是可能的原因及排查方向:

  • 文件权限不符:Drush以www用户执行,但sites/default/files/cache等缓存目录的权限或文件归属设置错误,导致Drush无法读写缓存文件,实际未完成清理。检查目录权限,确保www用户拥有完整的读写权限。
  • 缓存后端配置不一致:如果站点使用了Redis、Memcached等外部缓存服务,Drush加载的配置(如settings.php)可能与后台面板使用的配置不同,导致Drush清理的缓存并非站点实际使用的缓存存储。核对Drush执行时的配置加载路径,确保与后台一致。
  • Bootstrap阶段不完整:从日志可见Drush仅bootstrap到phase 2(站点初始化阶段),未完成完整的Drupal bootstrap(phase 5)。部分缓存(如主题、Twig模板缓存)需要完整的环境才能触发清理,尝试执行drush cr --bootstrap=full强制完整初始化后重建缓存。
  • 主题/模板缓存未被覆盖:drush cr可能未完全清理主题相关缓存,可尝试单独执行drush cache:clear theme或drush twig:compile针对性清理主题和Twig模板缓存,验证是否生效。
  • 服务器字节码缓存干扰:服务器启用OPcache等PHP字节码缓存时,修改后的模板文件可能仍被OPcache缓存,导致Drupal缓存清理后PHP仍加载旧文件。检查OPcache配置,开启自动刷新或手动执行opcache_reset()清除字节码缓存。
  • Drush版本或配置问题:Drush版本与Drupal 10.1.6不兼容,或缺少站点级Drush配置文件(日志提示未找到sites/default/drush.yml),导致缓存重建逻辑异常。更新Drush到兼容版本,或创建站点级Drush配置文件并配置正确的缓存参数。

内容的提问来源于stack exchange,提问作者Eugene B.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 08:05:28