Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: {exp:speedy:static} regenerating every single time page is loaded if “url_override” or “url_prefix” parameters used.

Status Resolved
Add-on / Version Speedy Speedy 1.5
Severity
EE Version EE 6.2.2

Aasun Eble

Jan 19, 2022

Using speedy static caching.

All working well for all other 47,000+ pages on the site.  But, the home page is problematic. 

All static files are stored in the default location:
/httpdocs/static/default_site/static/

Then, the template group structure is mirrored.  I’m not using any URL overrides, or anything like that on the templates.  All default settings for the cache creation.

This means that the home page cache file location is:
/httpdocs/static/default_site/static/index.php

about us cache file is:
/httpdocs/static/default_site/static/about-us/index.php

etc for all other pages in the site.

When the cache is cleared for the home page (on a save, or a manual clear of that cache file), the next page that is hit on the site (even if it’s not the home page) is getting placed at:
/httpdocs/static/default_site/static/index.php

So, then the next time the home page is hit, that cache file is served (as expected). Except that it’s not the home page content.. It’s whatever page was first hit after the home page cache file was removed.  I can’t determine why this would be happening. Again, it’s only the home page.. None of the other 47,000+ pages on this site are exhibiting this behavior.

So, I thought I would use the url_override or url_prefix in order to specify where the cached file is stored.  That way, I’d place the home page cache file in:
/httpdocs/static/default_site/static/home/index.php
rather than
/httpdocs/static/default_site/static/index.php

So, I’ve tried the following tag on my home page template:
{exp:speedy:static url_override="home}
as well as
{exp:speedy:static url_prefix="home}

Both of them seem to work, as far as creating a /home directory in my static file location, with index.php inside that directory. And having that file be the home page content (consistent with how all my other static cache files are created). 

BUT, that cache file is regenerated after each new page load.  So, the cached version of the page is never actually used.

Not sure which issue should be addressed first.  Maybe these should be broken into two separate tickets?

#1

BoldMinded (Brian)

Jan 19, 2022

How is your htaccess file configured? Sounds like it’s not routing correctly? It’ll take some time for me to try to replicate this locally. If it ends up being an htaccess issue that isn’t something I support as noted in the docs. So many other things in htaccess or with server config could be messing up the routing that is out of scope of support. Like I said, I’ll see if I can replicate it locally but until then you should confirm the htaccess file is correctly trying to find and load the home page cache file.

#2

Aasun Eble

Jan 20, 2022

Further testing has found the issue that started this.

problem:
Homepage URL:
“domain.com”

writes a cache file to:
/static/default_site/static/index.php
This is Correct.

Internal page:
“domain.com/wedding/url-title”

writes a cache file to:
/static/default_site/static/wedding/url-title/index.php
This is Correct.

BUT. some copy and paste URLs from dropbox to an email added a non-breaking space character to the end of the wedding URL:
“domain.com/wedding/url-title “
  (that non-breaking space character was invisible to the user, but the browser URL-encoded it and it shows in the server logs as: domain.com/wedding/url-title%C2%A0

that writes a cache file to:
/static/default_site/static/index.php
This is Incorrect.  This was overwriting the home page cache file.

Testing this with a regular ending space, or a trailing slash, and no issues.  Technically, a non-breaking space character would be interpreted as a completely different URL as the same URL without the non-breaking space character. (as if it was ending in an “a” or a “b”, etc.  the literal character.)  But, I would expect the cache file to be written in the similar URI location as the version of the URL without a nonbreaking space trailing character. (/static/default_site/static/wedding/url-title /index.php) Instead, it looks like it was breaking the speedy static file location and just defaulting that to the root static file location (which is what was overwriting the home page cache file).

We’ve added rewrites in our nginx config to account for those trailing non-breaking space characters., rewriting the URL to direct to the canonical version of the URL.  So, the issue is fixed for us. BUT, speedy probably has a bug in it that prevents it from handling that particular character correctly.

Again, the server logs showed that non-breaking space character URL-encoded as:
%C2%A0

#3

BoldMinded (Brian)

Jan 20, 2022

Wow, good debugging to find that, which is definitely odd behavior. Looks like I might have to add something to trim and clean the cache keys. Glad you got it worked out locally. I’ll take a look at adding a Speedy specific fix for this soon.

Login to reply