WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP Super Cache] WP Super Cache in conjunction with qTranslate (6 posts)

  1. Måns Jonasson
    Member
    Posted 5 years ago #

    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 http://www.example.com/ - however, the English language home page is http://www.example.com/en/

    And this is the problem - http://www.example.com/en/ and http://www.example.com/ 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,
    /Måns

  2. Måns Jonasson
    Member
    Posted 5 years ago #

    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.

  3. Donncha O Caoimh
    Member
    Posted 5 years ago #

    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.

  4. Måns Jonasson
    Member
    Posted 5 years ago #

    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?

  5. Donncha O Caoimh
    Member
    Posted 5 years ago #

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

  6. krekr
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic