Support » Plugins » [Plugin: WP Super Cache] WP Super Cache in conjunction with qTranslate

  • Hello,

    I am using WP Super Cache on a couple of sites with great results.

    However, one site I just launched is using the plugin qTranslate to provide multilingual support for the pages.

    On this site, WP Super Cache seems to get confused as to what to cache, and is ending up breaking the site when Super Cache is enabled. With Half-on mode the caching works fine.

    My best guesstimate is that WP Super Cache gets confused with what to cache because qTranslate is using some internal rewrite technique to determine what language to show, by prefixing all WordPress URL:s with a language code if not default.

    So, to display the “home page” of our site in Swedish (which is the default language in qTranslate for us), the URL is just – however, the English language home page is

    And this is the problem – and both show up in whatever language was displayed upon the initial caching attempt.

    So, I guess my question is – how does WP Super Cache determine what the URL of the page is?

    Thank you,

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’ve determined that qTranslate makes changes to $_SERVER[“REQUEST_URI”], stripping the language prefix from the URL so that WP Super Cache sess no difference between /en/content and /content, which leads to the problems described above.

    A temporary fix I implemented was to make changes to wp-cache-phase2.php and more specifically the function get_current_url_supercache_dir() which determines the name of the current URL to be cached.

    I’ve added a call to the qTranslate language function as such:

    $uri = "/" . qtrans_getLanguage() . $uri;

    This is an ugly way to fix this, since this will break if I upgrade WP Super Cache in the future, but I saw no other option for now.

    I’m not sure about the qTranslate behaviour of “breaking” the $_SERVER[“REQUEST_URI”] data. I’d be able to solve the WP Super Cache much more elegantly if that variable (or another one!) was left intact.

    You can use the “supercache_dir” filter rather than modifing the source code to modify that directory. You should contact the qtranslate plugin author to suggest he add a hook on that filter.

    Thank you donncha,

    but could you please elaborate? Do you mean that I could instead modify qTranslate to use the “supercache_dir” filter to set the exact uri to cache?

    Yeah, qtranslate should use that filter to modify the path to the cache file.



    I added “&lang=*” to the “pages not to be cached” list, which seems to work for me. Most of my visitors come for one language only, which doesn’t have any “&lang=” in its urls.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: WP Super Cache] WP Super Cache in conjunction with qTranslate’ is closed to new replies.