-
-
Notifications
You must be signed in to change notification settings - Fork 571
[5.x] Fix static caching of requests with trailing dot in host #11714
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
Conversation
That's wild to me that the domain with the trailing dot works at all. I feel like this should be resolved at the server level using a rewrite rule. This seems to work in nginx: if ($http_host ~ "\.$" ){
rewrite ^(.*) $scheme://$host$1 permanent;
} |
Yeah it's very surprising, and the only reason we even know this is possible is because we actually had a website break due to someone visiting our website with such a trailing I still feel like it's kind of awkward to semi-require an nginx config like this in every installation of Statamic. Do you think it'd be nicer to, instead of this, have a permanent redirect from Statamic itself? |
Domain names ending in dot are completely valid and documented separately in the RFCs
Which is why DNS, Nginx and Laravel handle it instead of dropping or redirecting it. I do think we'll want to fix this somewhere in Statamic, as this documented behavior is causing issues due to caching. The biggest problem is when cache is cleared, the homepage is cached with the Which is why a couple possible solutions are:
However in both cases redirecting domains with the |
My issue is more that we shouldn't have to add handling like this to one specific feature. I'm sure there will be instances of other parts of the framework/cms that arise if you try to do stuff with a trailing dot. You configure your APP_URL to be I'd be more open to a middleware or something that redirects the trailing dot to the non-trailing dot URL. Plus in this PR you are making the dot part of the path. I would probably expect Statamic to normalize |
That's absolutely fair and how most sites seem to solve the issue. Most sites seem to deal with it by simply redirecting: And some large sites do actually break because they don't handle this: I'll create a PR to implement a middleware removing the see: #11782 |
Fixes #11504
I've added a quick check here that makes sure any requests with a trailing dot get cached in a separate folder, as well as a test case that makes sure that it works.
Alternatively, we could just not make it cache these at all? I'm not sure what the best approach here is.