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

To avoid stressing the Exact Online docs an html cache should be introduced. #187

Closed
DannyvdSluijs opened this issue Jan 28, 2022 · 2 comments
Labels
good first issue Good for newcomers

Comments

@DannyvdSluijs
Copy link
Owner

To avoid stressing the Exact Online docs an html cache should be introduced. This would also speed up a secondary run when you're working on local changes which don't require refetching of the HTML. An option should be included to skip caching

@DannyvdSluijs
Copy link
Owner Author

Something like

private function fetchHtmlFromUrl(string $url): string
    {
        [,$basename] = explode('=', $url);
        $filename = sys_get_temp_dir() . '/exact-online-meta-data-tool-' . strtolower($basename) . '.html';

        if (!file_exists($filename)) {
            $html = file_get_contents($url);
            file_put_contents($filename, $html);
        } else {
            $html = file_get_contents($filename);
        }

        $this->visitedPages->add($url);

        if ($html === false) {
            throw new \RuntimeException('Unable to fetch html from ' . $url);
        }

        return $html;
    }

Can already help.

@DannyvdSluijs
Copy link
Owner Author

Solved in #194

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

No branches or pull requests

1 participant