{"action":"created","issue":{"url":"https://api.github.com/repos/herrvigg/qtranslate-x/issues/306","repository_url":"https://api.github.com/repos/herrvigg/qtranslate-x","labels_url":"https://api.github.com/repos/herrvigg/qtranslate-x/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/herrvigg/qtranslate-x/issues/306/comments","events_url":"https://api.github.com/repos/herrvigg/qtranslate-x/issues/306/events","html_url":"https://github.com/herrvigg/qtranslate-x/issues/306","id":335088670,"node_id":"MDU6SXNzdWUzMzUwODg2NzA=","number":306,"title":"Problems with cached 302 language redirects with W3 Total Cache browser caching","user":{"login":"herrvigg","id":19155375,"node_id":"MDQ6VXNlcjE5MTU1Mzc1","avatar_url":"https://avatars2.githubusercontent.com/u/19155375?v=4","gravatar_id":"","url":"https://api.github.com/users/herrvigg","html_url":"https://github.com/herrvigg","followers_url":"https://api.github.com/users/herrvigg/followers","following_url":"https://api.github.com/users/herrvigg/following{/other_user}","gists_url":"https://api.github.com/users/herrvigg/gists{/gist_id}","starred_url":"https://api.github.com/users/herrvigg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/herrvigg/subscriptions","organizations_url":"https://api.github.com/users/herrvigg/orgs","repos_url":"https://api.github.com/users/herrvigg/repos","events_url":"https://api.github.com/users/herrvigg/events{/privacy}","received_events_url":"https://api.github.com/users/herrvigg/received_events","type":"User","site_admin":false},"labels":[{"id":971666665,"node_id":"MDU6TGFiZWw5NzE2NjY2NjU=","url":"https://api.github.com/repos/herrvigg/qtranslate-x/labels/enhancement","name":"enhancement","color":"a2eeef","default":true},{"id":971679229,"node_id":"MDU6TGFiZWw5NzE2NzkyMjk=","url":"https://api.github.com/repos/herrvigg/qtranslate-x/labels/import","name":"import","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2018-06-23T10:27:48Z","updated_at":"2018-06-23T10:28:22Z","closed_at":null,"author_association":"OWNER","body":"<a href=\"https://github.com/lklapa\"><img src=\"https://avatars1.githubusercontent.com/u/13730155?v=4\" align=\"left\" width=\"96\" height=\"96\" hspace=\"10\"></img></a> **Issue by [lklapa](https://github.com/lklapa)**\n_Friday Nov 06, 2015 at 18:33 GMT_\n_Originally opened as https://github.com/qTranslate-Team/qtranslate-x/issues/306_\n\n----\n\nI have faced a bug that prevents qTranslate-X from switching languages properly. I'm using WordPress 4.3.1 and qTranslate-X 3.4.6.4. My setup has two languages: pl (default) and en.\n\nSteps to reproduce:\n1. Visit http://website.domain/, and detected language is PL (my browser's locale) - all fine.\n2. Switch to EN, and in network console log I can see a 301 redirect to /en/ - the website is now in EN as expected - correct.\n3. Visit once again http://website.domain/, and resulting page comes in EN - correct.\n4. Visit once again http://website.domain/, **but this time the 302 redirect is being served from browser's cache**.\n5. Now, when you try to switch the website back to the default language (PL), the network log shows a request to /pl, then the server responds with a redirect to / (as I'm using an option to hide the default language), and now **browser cache interferes** saying according to the result cached in step 4, that / should be redirected to /en.\n\nAt this stage it is impossible to switch back to the default PL language, as all requests looking for GET / are from now on treated according to browser cache, so GET / = [cached 302] = GET /en.\n\nEven without the option to hide the default language, visiting http://website.domain/ still uses browser's cache, so I'm ending up in a redirection leading me towards /en until I clear the cache.\n\nSuch behavior is not observed if I disable web browser cache option in W3 Total Cache plugin.\n\nThe solution:\ninside `qtranxf_init_language` function (line 80), there is a call to `wp_redirect()`.\n\nChanging it from:\n\n```\nwp_redirect($target);\n```\n\nto:\n\n```\nwp_redirect($target, 303);\n```\n\nsolves the issue for me, as 303 redirects according to the standard are not to be cached in the browser. \n\nAny chance for changing this redirect in the next qTranslate-X release?\n\n"},"comment":{"url":"https://api.github.com/repos/herrvigg/qtranslate-x/issues/comments/399663026","html_url":"https://github.com/herrvigg/qtranslate-x/issues/306#issuecomment-399663026","issue_url":"https://api.github.com/repos/herrvigg/qtranslate-x/issues/306","id":399663026,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTY2MzAyNg==","user":{"login":"herrvigg","id":19155375,"node_id":"MDQ6VXNlcjE5MTU1Mzc1","avatar_url":"https://avatars2.githubusercontent.com/u/19155375?v=4","gravatar_id":"","url":"https://api.github.com/users/herrvigg","html_url":"https://github.com/herrvigg","followers_url":"https://api.github.com/users/herrvigg/followers","following_url":"https://api.github.com/users/herrvigg/following{/other_user}","gists_url":"https://api.github.com/users/herrvigg/gists{/gist_id}","starred_url":"https://api.github.com/users/herrvigg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/herrvigg/subscriptions","organizations_url":"https://api.github.com/users/herrvigg/orgs","repos_url":"https://api.github.com/users/herrvigg/repos","events_url":"https://api.github.com/users/herrvigg/events{/privacy}","received_events_url":"https://api.github.com/users/herrvigg/received_events","type":"User","site_admin":false},"created_at":"2018-06-23T10:28:22Z","updated_at":"2018-06-23T10:28:22Z","author_association":"OWNER","body":"<a href=\"https://github.com/johnclause\"><img src=\"https://avatars2.githubusercontent.com/u/5491361?v=4\" align=\"left\" width=\"48\" height=\"48\" hspace=\"10\"></img></a> **Comment by [johnclause](https://github.com/johnclause)**\n_Saturday May 07, 2016 at 18:42 GMT_\n\n----\n\nI updated https://github.com/qTranslate-Team/qtranslate-x/archive/stable.zip with a change. WP even have a function `nocache_headers()` for such a case ;)\n\nI am closing this issue, assuming it works now, please test, we can still write into closed issue and we can re-open it if needed. Thank you all for your help.\n\n"}}
{"actor":{"display_login":"herrvigg"}}