Kirby generating non-secure URLs after moving servers

This situation is similar to what was reported in a previous thread: I moved a site from one server to another, and in the new server, wherever there is a url() function, the generated URL comes out with http instead of https.

This seem to apply to everything: $site->url(), thumb()->url(), $asset->url(), etc.

Locally - using MAMP - the site appears fine, and Kirby generates the URLs appropriately. In the new server, the site seems broken. Except that the new server has other Kirby sites in it, running without any issues, with exactly the same configuration…

I’m stumped - don’t quite know what to try next… Any suggestions would be greatly appreciated!

I think I’ve pinpointed the issue: Kirby’s built-in cache.

I tried using $site->purge(), but it did nothing. Also tried deleting the entire contents of the “/cache” server - still no help.

Finally, I looked at the config.php file, and deleted the ‘cache’ setting. Bingo! It worked: without caching, Kirby started generating “https” URLs again.

The tricky part is, however, that the site is using memcached for caching - that’s why deleting the contents of “/cache” didn’t help.

So, is there an easy, ‘Kirby way’ to purge the cache from memcached?

Should be $kirby->cache()->flush()?

Merry Christmas, @texnixe! :christmas_tree:

Your suggestion might work, and so might $site->purge(), or any of the purge() function. The problem is: where do I put that function, once the site pages are already being served from cache? Updating the template doesn’t seem to work…

For future reference, in case someone else comes across the same issue, here is how this problem happens:

  1. Move the site to a new server, but the new server does not YET have SSL enabled.

  2. Visit the site - e.g., to test it - while the server still doesn’t have SSL. This will immediately create cached versions of the visited pages, all of which will have insecure ‘http’ URLs, auto-generated by Kirby (which, at this point is totally correct).

  3. Enable SSL on the site.

  4. Visit the site again: now, even though the site itself is being accessed via https, it’s serving pages from cache, which have ‘http’ URLs - which cause all kinds of issues on current browsers.

If the cache is being kept in the “/cache” folder, you’re in luck: just deleting the cached files there should be enough to re-generate them with the correct, secure URLs. If you’re using memcached, however, it’s a bit tricky - because you have to issue a command to memcached to delete the cache.

The cache()->flush() or purge() functions should do it, but the problem is getting the server to actually run them. Now that our pages are in memcached, it seems making a template change - e.g., adding one of these functions to a global snippet - doesn’t trigger the cache to refresh. Perhaps this is a bug?

In any case, I seem to remember there being a plugin that ‘cleared the Kirby cache’, but for me it was simply easier to ssh into the server and clear the memcached data manually. That fixed it, but it’s probably not something the average user can do. This got me thinking that maybe the Panel should include a ‘clear cache’ button somewhere, by default…

You could also use an authentication protected route or @bnomei’s Janitor button.