Force Browser Cache clearing

Hello,

sometimes I need to clear my users browser cache if I for example add a new button to the CKEditor or change some CSS.
Is there a way to force the users browser to clear their cache via an Option or script in XWiki?
I tried

{{velocity}}
$services.lesscss.clearCache()
{{/velocity}}

which i found here https://extensions.xwiki.org/xwiki/bin/view/Extension/LESS%20Module but it didnt work. Im using Version 10.11.8.

(I come from a DokuWiki background where I could force my user’s browsers to refresh their cache for the wiki, when I did a change in the config.php file).

Greetings

That’s more a standard Javascript question than a XWiki one (unfortunately I have no idea on my side).

{{velocity}}
$services.lesscss.clearCache()
{{/velocity}}

This is not related to the browser cache, this is less cache on the server side (the result of less -> css compilation).

hi OezDur,

How do you currently change the CSS? One possible option is to use an XWiki StyleSheetExtension either at the wiki level or at a page level, or on demand. XWiki will then automatically add the version of that StyleSheet to its URL when including it, hence forcing the browser to load the ressource. If not enough, you can add an option yourself when including the StyleSheet extension, by adding some parameters to the call.

Regarding the CKEditor customization, it might be different, I’ll look that up separately, let us know how it goes with StyleSheet extensions already maybe?

Cheers

Regarding CKEditor, as far as I can see, the custom CKEditor configuration is loaded from application-ckeditor/webjar/[…]/config.js. An XWiki JavaScript extension forcing the reload of the CKEditor.Config parameters might be a path toward clearing the cache, not sure. Hoping this helps,

This is not related to the browser cache, this is less cache on the server side (the result of less -> css compilation).

Thanks for clearing that up!

Currently I am using both StyleSheetExtensions for some things and in the admin menu under the “advanced” tab in the menu where you can edit your wiki-theme I have some CSS code.

Thanks to your tip, I’ve put the CSS I had in the “advanced” tab into its own StyleSheetExtension and it got immidiatly applied, so thanks for that.

But there is a still a problem I think, you can test this yourself by changing some values in the Admin-Menu:

  • In the Admin-Menu > Look & Feel > Themes > Color Theme > Customize
  • Change for example for Panels the background color
  • After you’ve done that and go back to your wiki, the change wont take effect
  • You have to manually refresh your browser-cache to make the changes appear.

Also there is still the remaining issue with the CKEditor which isn’t as big a problem because if the Editor wont load the users will come to me and I can tell them to refresh.

The theme issue that you mention was actually reported in June, I just noticed: see issue XWIKI-16515.

Regarding StyleSheet extensions, you may have noticed that you can also activate the “no cache” option when configuring them.

Good to know hte CKEditor issue is not a big deal, that could be handy to let the configuration be more dynamic at some point if needed though.