Disable Template Manager Caching

4 posts, 0 answers
  1. CBARS
    CBARS avatar
    55 posts
    Member since:
    Sep 2008

    Posted 11 Mar 2009 Link to this post

    How do I disable Template Manager from caching the files?

    I added a save button in RadEditor, but Template Manager keeps reading the original file. Whenever I clear FF's cache, Template Manager inserts the correct files.
  2. Rumen
    Admin
    Rumen avatar
    14028 posts

    Posted 13 Mar 2009 Link to this post

    Hi Marcel,

    The caching is not related to the editor's template manager but to the browser caching mechanism.
    You can try to prevent the caching by using the instructions in these articles:
    How to prevent Firefox 3 from caching,
    How to prevent caching in Internet Explorer
    and
    Useful HTML Meta Tags.

    Best regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. John
    John avatar
    18 posts
    Member since:
    Nov 2006

    Posted 25 Jul 2009 Link to this post

    I think the instructions may work for pages, but not for the Editor template manager.
    I had following codes:
    1 protected void linkSaveCss_Click(object sender, EventArgs e)   
    2 {  
    3     if (SaveCssToFile(cssZone.Text, Server.MapPath(hdnCssFilePath.Value)) == true)   
    4     {  
    5         //editor.CssFiles.Clear();   
    6         //editor.CssFiles.Add(new EditorCssFile(string.Format("{0}?t={1}", hdnCssFilePath.Value, DateTime.Now.Ticks.ToString())));  
    7         Response.Buffer = false;     
    8         Response.ExpiresAbsolute = DateTime.MinValue;  
    9         Response.CacheControl = "no-cache";  
    10         Response.AddHeader("Pragma""no-cache");  
    11         Response.Expires = -1;  
    12         Response.Redirect(Request.Url.ToString());  
    13      }    
    14      else    
    15         header1.AlertMessage("Failed to save the CSS file. ");    
    16

    And I still get the cached style in both the editor and the template manager.
  4. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 29 Jul 2009 Link to this post

    Hi John,

    To disable the caching of the files loaded in the template manager dialog, you will need to make a small modification to the dialog code. In order to do it, you need to use the ExternalDialogsPath editor property to load the template manager from an external .ascx file. For an example of this, see the following editor demo - http://demos.telerik.com/aspnet-ajax/editor/examples/externaldialogspath/defaultcs.aspx.

    Once you have set up the TemplateManager.ascx as an external dialog, change the setItem JavaScript function to the following:

    setItem: function(item) 
        this._currentItem = item; 
        if (this._currentItem.get_type() == Telerik.Web.UI.FileExplorerItemType.File) 
        { 
            var url = this._currentItem.get_url(); 
            if (url) 
            { 
                url = url + (url.indexOf('?') != -1 ? "&" : "?") + "rndnum=" + (new Date() - 100); 
                this._currentTemplateItem.src = url; 
            } 
        } 
        else 
        { 
            this._currentTemplateItem.src = "javascript:''"
        } 
    }, 

    This will force the template manager to use a different url for the template files each time you select them in the file browser. The benefit of the change is of course that the files will no longer be loaded from the browser cache. However, we do not plan to include this change in the editor code, because it also slows down the loading time for each file considerably. Since you need to make a request to the server each time you click on a file, some scenarios will (e.g. distant server, big template files) will suffer if caching is removed.


    Regards,
    Lini
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top