Table of contents
- Cache generated problems
- How to bypass the cache after login with social login?
- Frequently Asked Questions
Cache generated problems
In some cases when users login to your site with social login, they might need to refresh or hard refresh the page manually to make login happen.
When this happens, that usually indicates a caching problem, in most cases it is connected to the cache-control response header.
Cache stored in the browser:
When the caching is enabled with the cache-control header, the browser will keep returning the earlier cached HTML of the results where the user was not logged in yet, although the login actually has already happened. You can confirm this simply by checking the cookies in the browser, and the two WordPress login cookies should appear there already:
- wordpress_sec_[hash]
- wordpress_logged_in_[hash]
As mentioned above hard refreshing the page clears this cache and usually pulls the correct results.
Cache stored on the server
Clearing the browser cache won’t help when the cached results are stored on the server. In these cases the user will only be able to see the logged in results on the pages that weren’t served from cache.
How to bypass the cache after login with social login?
When the “Bypass cache on redirect” setting is enabled, we will add a GET parameter to the URL, where we redirect after a successful login/registration with social login. If the cache is configured properly, then URLs with query parameters shouldn’t be served from cache, so this might solve the problem.
If this didn’t fix the problem either, then you might need to make some adjustments in the cache settings. The most common problems are the following:
- URLs with query strings are cached: Your cache is configured the way that URLs with query strings are also served from cache. To get this problem solved, you should get in touch with your host or the provider of the cache service, and ask them to disable the caching for the URLs with GET parameters.
( E.g.: If you use Cloudflare for caching, then you might need to adjust the Caching Levels to “No Query String”. ) - The site is always cached, so you need to force the non-cached results: The site will only display the live results if certain query parameters are added to the URL, which force the site the display the non-cached results. If you already know the name / value of the query parameter that you need to add to the URL, then over our filters you could modify the name and value of our “nsl_bypass_cache” parameter to the one that you need, as it is described below.
If you are not sure about how your cache works, then get in touch with your host or the company that provides the cache.
Frequently Asked Questions
Why is the “nsl_bypass_cache” parameter added to the URL?
When the “Bypass cache on redirect” setting is enabled at our Global Settings > General tab, we will add this GET parameter to the redirect URL to avoid caching. Disabling this option will make the “nsl_bypass_cache” GET parameter no longer being added to the redirect URLs. However if you decide on disabling this feature, then please check the login after that, so you can find out if you need this setting or not.
Can I change the name and value of the “nsl_bypass_cache” parameter?
Yes, if you hook a custom function to our “nsl_bypass_cache_url” action, then we won’t add our “nsl_bypass_cache” parameter to the URL, but instead we will use the URL that you return in the custom function.