Welcome Guest, Not a member yet? Register   Sign In
Delete Web Page Cache in CI4
#3

(This post was last modified: 06-19-2020, 03:23 AM by jreklund.)

It's based on a md5 hash of the full url of the page. This example are based on if you have cacheQueryString set to false and run in the Controller.

PHP Code:
// Get the current page url automatically, in case you want to store it somewhere.
$uri $this->request->uri;

$name = \CodeIgniter\HTTP\URI::createURIString($uri->getScheme(), $uri->getAuthority(), $uri->getPath());

echo 
md5($name);

// Get the current scheme and authority (includes domain) automatic, and append custom string.
$uri $this->request->uri;

$name = \CodeIgniter\HTTP\URI::createURIString($uri->getScheme(), $uri->getAuthority(), 'some/path');

echo 
md5($name);

// Build your own, so you can delete it somewhere else.

// http://example.com/
echo md5(\CodeIgniter\HTTP\URI::createURIString('http''example.com''/'));

// http://example.com/some/path
// DO NOT ADD / AT THE END!
echo md5(\CodeIgniter\HTTP\URI::createURIString('http''example.com''some/path')); 

You can of course specify the url manually if you like, you don't need to use createURIString. As long as the url matches, it will work.

The md5 generated are the $key in the above post.
Reply


Messages In This Thread
Delete Web Page Cache in CI4 - by benjaminbellamy - 06-18-2020, 05:55 AM
RE: Delete Web Page Cache in CI4 - by dave friend - 06-18-2020, 07:52 PM
RE: Delete Web Page Cache in CI4 - by jreklund - 06-19-2020, 03:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB