1

ON PUBLISH, Pdf media item is not clearing the cache from CD server in 9.3 and still shows the old pdf.

The HTML Cache clears as expected in the CD but not the media item. Eventqueue folder in the CD server has events triggered from the CM and not sure what particular record should I look for in the eventqueue. I see the below records in the eventqueue for publishing the pdf from CM in the CD web database of eventqueue table.

setting name="Media.AlwaysAppendRevision" value="true" This setting will NOT help as the urls within html embedded will have the old value.

enter image description here

2
  • The issue might be happening due to browser cache and not sitecore, there is a KB article related to this kb.sitecore.net/articles/218124. I assume the new pdf was published correctly to the web database. – Cristi Vulturar Feb 25 at 13:39
  • @CristiVulturar Yes the new pdf is published to the web database correctly so there is nothing in Sitecore that notifies the browser to get the new version. The MediaResponse.MaxAge is set 5 to minutes. How does App_Data\MediaCache work in the context of OnPublish event and is this expected behavior ? – SNew Feb 25 at 18:45
1

Sitecore provides a cleanup agent to clear older media files, which clears media files every specified interval of time. By default it clears all media cache files created 90 days ago. See below settings in sitecore.config:

<agent type="Sitecore.Tasks.CleanupAgent" method="Run" interval="06:00:00">
      <!-- Specifies files to be cleaned up.
              If rolling="true", [minCount] and [maxCount] will be ignored.
              [minAge] and [maxAge] must be specified as [days.]hh:mm:ss. The default value
              of [minAge] is 30 minutes.
              [strategy]: number of files within hour, day, week, month, year
              [recursive=true|false]: descend folders?
          -->
      <files hint="raw:AddCommand">
        <remove folder="$(dataFolder)/logs" pattern="*log.*.txt" maxAge="30.00:00:00" />
        <remove folder="$(dataFolder)/diagnostics" pattern="*.*" maxAge="30.00:00:00" recursive="true" />
        <remove folder="$(dataFolder)/viewstate" pattern="*.txt" maxAge="2.00:00:00" recursive="true" />
        <remove folder="$(tempFolder)/diagnostics" pattern="*.*" maxAge="00:10:00" recursive="true" />
        <remove folder="/App_Data/MediaCache" pattern="*.*" maxAge="90.00:00:00" recursive="true" />
      </files>
    </agent>

It is not recommended to clear media cache very often because you will have some performance impact.

I would say this is expected behavior since the file is cached by the browser since it accessed the file previously. If you want to force the cache clear for the changed image you would need to change the url in your embedded html and add for example a modified value in the url, similar to the approach described Forcing Sitecore to clear the cache for updated images

2
  • @ChristiVulturar Is there a way to update all pdf media item link references to be updated when pdf gets updated because an author cannot go back to edit all the html content where it is hyperlinked to add date modified to the query string? and I am not following what is the use of cleaning mediacahe folder often when the updated pdf gets updated in the mediacache either way as soon as it is published and the next visitor would get the latest pdf. Am I missing anything here ? – SNew Feb 26 at 16:29
  • If Media.AlwaysAppendRevision doesn't work in your case, I think you could take a look at creating a new mediaprovider like in the post linked in the answer above. Not sure how is the pdf updated by the editors in your case (and not creating a new media item) and how it is embedded in the rich text html, but if you can identify these media items for example you can only add the &modified querystring for them. – Cristi Vulturar Feb 26 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.