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

SSI includes always passing to index.php #595

Closed
luizboaretto opened this issue Dec 19, 2023 · 14 comments
Closed

SSI includes always passing to index.php #595

luizboaretto opened this issue Dec 19, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@luizboaretto
Copy link

I have SSI includes

<!--#include virtual="/_includes/?action=blitz/include/cached&index=2395729283" -->

in the cache directory I have 'action=blitz%2Finclude%2Fcached&index=2395729283'

Tested with nginx and apache

Apache config:

RewriteCond %{DOCUMENT_ROOT}/cache/blitz/%{HTTP_HOST}/%{REQUEST_URI}/%{QUERY_STRING}/index.html -s
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} !token= [NC]
RewriteRule .* /cache/blitz/%{HTTP_HOST}/%{REQUEST_URI}/%{QUERY_STRING}/index.html [L]

nginx config:

#- Blitz cache rewrite
set $cache_path false;
if ($request_method = GET) {
    set $cache_path /cache/blitz/$host/$uri/$args/index.html;
}
if ($args ~ "token=") {
    set $cache_path false;
}

#- Send would-be 404 requests to the cache path or Craft
location / {
    ssi on;
    try_files $cache_path $uri $uri/ /index.php?$query_string;
}
@luizboaretto luizboaretto added the bug Something isn't working label Dec 19, 2023
@bencroker
Copy link
Collaborator

What is the question or issue?

@luizboaretto
Copy link
Author

What is expected is that nginx or apache will serve the includes that are cached and not go through index.php

@bencroker
Copy link
Collaborator

bencroker commented Dec 19, 2023

This should work. Do you have an _includes folder containing each of the cached includes in the cache directory?

@luizboaretto
Copy link
Author

luizboaretto commented Dec 19, 2023

For sure, as I mentioned in my first comment:

in the cache directory I have 'action=blitz%2Finclude%2Fcached&index=2395729283' folder

web/cache/blitz/staging.portal.com/_includes/
├── action=blitz%2Finclude%2Fcached&index=2320311357
│   └── index.html
├── action=blitz%2Finclude%2Fcached&index=2395729283
│   └── index.html
├── action=blitz%2Finclude%2Fcached&index=2640481881
│   └── index.html
├── action=blitz%2Finclude%2Fcached&index=289657702
│   └── index.html
├── action=blitz%2Finclude%2Fcached&index=3023494763
│   └── index.html
├── action=blitz%2Finclude%2Fcached&index=3201798021
│   └── index.html
├── action=blitz%2Finclude%2Fcached&index=3891590775
│   └── index.html
└── action=blitz%2Finclude%2Fcached&index=703993243
    └── index.html

8 directories, 8 files

I think some issues with slashes and %2F

@luizboaretto
Copy link
Author

luizboaretto commented Dec 19, 2023

if I change:

from:
<!--#include virtual="/_includes/?action=blitz/include/cached&index=2395729283" -->

to:
<!--#include virtual="/_includes/?action=blitz%2Finclude%2Fcached&index=2395729283" -->

works!

@bencroker
Copy link
Collaborator

bencroker commented Dec 19, 2023

And you’re running the latest version of Blitz? I believe this was addressed in 4.6.0.

@luizboaretto
Copy link
Author

Blitz 4.9.3
Craft Pro 4.5.13
PHP 8.2.11

And tested on
Apache/2.4.58
nginx/1.18.0

@luizboaretto
Copy link
Author

And you’re running the latest version of Blitz? I believe this was addressed in 4.6.0.

I think this the problem... you are not encoding the url and on the server it is encoded. I understand that the webserver should know this, but something is wrong. I don't know if it's a lack of configuration on my side or if it would be best to normalize this

@bencroker
Copy link
Collaborator

It sounds like the folders in the _includes directory might be leftovers from before the 4.6.0 release. Can you delete the _includes directory and test whether they are recreated without encoded slashes?

@luizboaretto
Copy link
Author

I started this project in November... this is a new fresh server and clean database, etc...

I'm pretty sure I'm already way ahead of 4.6.0

@luizboaretto
Copy link
Author

I cleared all possible cache, but it's still the same thing

@bencroker
Copy link
Collaborator

bencroker commented Dec 19, 2023

I’m wondering if the change in 4.6.0 was redundant, after all.

Can you please install and test this bug fix, clearing the cache first, by running composer require "putyourlightson/craft-blitz:dev-bugfix/undo-decode-slashes as 4.9.4"?

@luizboaretto
Copy link
Author

luizboaretto commented Dec 19, 2023

It works! 🥇

@bencroker
Copy link
Collaborator

Changed and released in 4.9.4, thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants