Refreshing Dynamic Configuration Files

For many sites, it can be useful to have different configuration files based on the actual content being edited. For instance, the image and hyperlink lists may be dynamically generated to include only what's relevant to the current page or change where images are uploaded to etc. The first time people try this they tend to run into the caching that EditLive! performs and find that the config file is never reloaded. The reason EditLive! caches this file so heavy-handedly is that we've found that the slowest part of EditLive! starting up is quite often downloading the configuration file and everything else has to wait for that download to finish.

If you really need to the configuration file to update there are a couple of simple ways to achieve it. The best way is to use setConfigurationText instead of setConfigurationFile which provides the config inline in the web page and removes the need to for another HTTP request altogether. EditLive! won't perform any caching of the config in this case so your changes will appear immediately. We strongly recommend taking this approach even if your configuration file never changes to make the editor load faster.

If however you absolutely have to download a separate URL, or if you just want a quick work around and load time isn't an issue for you, then you can simply append a dummy parameter to the end of the URL which will force EditLive! to download it again each time. The current timestamp is generally a good value to use, for example:

editlive.setConfigurationFile("eljconfig.jsp?cacheBuster=" + new Date().getTime());

Just remember that the extra HTTP request is going to cause a delay in the editor loading, so you'll get a big benefit from using setConfigurationText instead.

See also: setConfigurationText in the EditLive! SDK

Adrian spends his days working out ways to make life easier for Ephox clients through initiatives like LiveWorks! Previously a senior engineer, he has now moved on to the fancier sounding title of CTO.

Leave a Reply