Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 713 posts 954 karma points
    Mar 10, 2014 @ 03:06
    Tom
    0

    Force Published Cache Refresh For Media

    Hi All,

    Having issues when we deploy a site including media client may have loaded in prior to deploy.

    It appears the published cache gets out of sync so I'm wondering how we force it to clear and refresh rather than going through each media node and hitting save.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 10, 2014 @ 12:11
    Jeroen Breuer
    0

    You could use this code (old API example) to save all the media.

    protected static umbraco.DataLayer.ISqlHelper SqlHelper
    {
        get { return umbraco.BusinessLogic.Application.SqlHelper; }
    }

    public static void SaveMedia() { try { string sql = @" select un.id from umbracoNode un where un.nodeObjectType = @type"; //Get all the media items. using (IRecordsReader dr = SqlHelper.ExecuteReader(sql, SqlHelper.CreateParameter("@type", Media._objectType))) { //Loop trough all the media items. while (dr.Read()) { //Get the id of a media item. int mediaId = dr.GetInt("id"); //Resave media Media media = new Media(mediaId); media.Save(); media.XmlGenerate(new XmlDocument()); } } } catch (Exception ex) { } } 

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft