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

Sitecore中web.config的CleanupAgent节点补丁配置需求

How to Add a JSON Cleanup Rule to Sitecore's CleanupAgent

Alright, let's get that cleanup rule set up correctly. First, make sure you're targeting the right section of your web.config file—we're focusing on the CleanupAgent under the root <sitecore> node.

Direct web.config Edit

If you're modifying the core web.config directly, simply insert your new <remove> node inside the <files hint="raw:AddCommand"> collection. Here's what the updated section will look like:

<sitecore>
  <!-- Other Sitecore config nodes -->
  <agent type="Sitecore.Tasks.CleanupAgent">
    <files hint="raw:AddCommand">
      <!-- Your existing cleanup rules go here -->
      
      <!-- The new rule you need to add -->
      <remove folder="/App_Data/MediaCache" pattern="*.json" maxAge="01.00:00:00" recursive="true" />
    </files>
  </agent>
  <!-- Other Sitecore config nodes -->
</sitecore>

Editing the core web.config directly isn't ideal—it can get overwritten during Sitecore upgrades. Instead, create a custom patch file (e.g., App_Config/Include/Custom/MediaCacheCleanup.config) with this content:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <agent type="Sitecore.Tasks.CleanupAgent">
      <files hint="raw:AddCommand">
        <remove folder="/App_Data/MediaCache" pattern="*.json" maxAge="01.00:00:00" recursive="true" patch:after="remove[@folder='/App_Data/MediaCache']" />
      </files>
    </agent>
  </sitecore>
</configuration>

The patch:after attribute ensures your new rule gets added after any existing remove rules targeting the MediaCache folder—adjust the selector if you need to place it elsewhere in the collection.

Key Notes:

  • Don't forget to close the <remove> tag with /> (your original snippet was missing this closing slash).
  • The maxAge="01.00:00:00" setting will automatically delete any JSON files older than 1 full day.
  • recursive="true" tells the cleanup agent to scan and clean all subfolders within /App_Data/MediaCache, not just the root of the folder.

内容的提问来源于stack exchange,提问作者Chives

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 07:49:12