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

Doctype check failure edge case #341

Open
koskinenaa opened this issue Sep 15, 2024 · 0 comments
Open

Doctype check failure edge case #341

koskinenaa opened this issue Sep 15, 2024 · 0 comments

Comments

@koskinenaa
Copy link

Issue:
The $html_doctype_regex check in Cache_Enabler_Engine::is_cacheable() fails, if there's a HTML comment before the <!doctype html> tag.

Backgroud:
I installed the plugin to a site I manage and was puzzled why the site wasn't getting cached. After some digging and stepping through the plugin source code one step at a time I figured out that the content was not cacheable due to $html_doctype_regex check failing.

The site in question uses a theme developed by a 3rd party. They've added their logo as a HTML comment before the <!doctype html>. The regex apparently expects the doctype to be the first thing in the source content and so the check fails due to the preceding comment.

Solution:
Although this is just one edge case and easy to fix by removing the unneccesary comment, I wanted to let you know about in case you decide to tweak the regex to take into account any extra characters before the doctype tag. Unfortunately regex is like black magic to me so I don't have anything to propose how to tweak it.

Suggestion:
It would be nice, if the plugin had some kind of logging or debugging feature, which would tell you why the caching failed. It might save some time in figuring out what's wrong with the site in situations like the above.

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

1 participant