Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HtmlCahe caches only one page and shows this pages to all pages #31

Open
kruglikoves2 opened this issue Sep 9, 2020 · 2 comments
Open

Comments

@kruglikoves2
Copy link

kruglikoves2 commented Sep 9, 2020

We had the next problem:
HtmlCahe caches only one page and shows these pages to all pages. We had this problem.
The problem was that to get request URL, the plugin uses request->getParam('p'). It's '' an empty string in our system occasionally. So we created "p" query string in our module to fix this problem.

And here is the code that did this:

class HtmlCachePluginBugFixer
{
    private $request;
    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    // HtmlCache Plugin have the issue - it requires query parameter p with page url for work.
    // This method fixes this issue.
    public function fixMissingPParameterInRequest()
    {
        $uri = $this->request->getUrl();
        $requestQueryParams = $this->request->getQueryParams();
        $requestQueryParams['p'] = $uri;
        $this->request->setQueryParams($requestQueryParams);
    }
}

And here is how it executes in our module:

        $htmlCachePluginBugFixer = new HtmlCachePluginBugFixer(\Craft::$app->request);
        $htmlCachePluginBugFixer->fixMissingPParameterInRequest();
@Coysh
Copy link

Coysh commented Sep 28, 2020

I also have this problem - the above fix didn't work for me.

@kruglikoves2
Copy link
Author

I also have this problem - the above fix didn't work for me.

Strange. Worked for me. We've added the fix in our custom module code.
Where did you added the fix code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants