Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Multilingual and cache

Go to End

8 Posts   1972 Views


Community Member, 17 Posts

7 January 2009 at 5:09pm

Is there anyway to avoid using HTTP::set_cache_age(0) in the config.php file when switching between multi-lingual pages where translated pages share the same URL as the original page? I don't want to disable the cache on the CMS because of the performance hit.

If not, what are the alternatives? Should I append a ?lang=en at the end of each href link in the HTML code to specify the language and prevent the page from being loaded from the cache whenever user switches languages? What is the best way to avoid using set_cache_age(0) in config.php?



Administrator, 690 Posts

8 January 2009 at 2:25pm

Putting ?lang=en explicitly on the end of the URL is probably the best way.


Community Member, 17 Posts

9 January 2009 at 1:09am

Cheers Sam.

My question then is how can I automatically put ?lang=en at the end of the URLs created using the WYSIWYG editor in the CMS?



Community Member, 17 Posts

15 January 2009 at 5:10pm

Okay, I found a simple solution to this problem using JQuery.

I just use something like $('a') in JQuery to get an array of all the links in the page, and then use Javascript to append ?lang=en to the end of each URL in the code.



Community Member, 126 Posts

3 February 2009 at 11:42pm

there are many comments in the forum on the 'translatable' being overhauled in the 2.4 release - for now, it's still kind of a mess - UI troubles and the url problem you mentioned kept me away from using it.

nevertheless, the cms itself is great work, so i stayed with it and found a way around based on this (2 years old) thread:

in short, it enables me to have separate fields for the translated content, which will be shown when you have a language prefix in your url like '' or ''.
presumably not the most clever solution, but it works - i'd be willing to share the code in case anyone's interested (just reply).


Community Member, 22 Posts

4 February 2009 at 3:13am

@schellmax: I would be appreciate if you can share this implementation!

I totally agree with your comments to the unfinished translation module.

Many thanks, Bjoern


Community Member, 791 Posts

4 February 2009 at 11:11am

A similar solution can be found in the comments at:


Community Member, 126 Posts

5 February 2009 at 6:57am

@bschmitt: i've just added a recipe in the docs:

@Fuzz10: thanks for the hint, in fact my solution is pretty similar to yours (re-invention of the wheel...) but not exactly the same (regarding the more generalized approach of translatable fields and the url building) - i'd love to hear your comments on this.

i created a thread for this topic, please feel free to post there:

have a nice day