Closed JoeriE closed 3 days ago
What is your NGINX config?
@ryanmitchell This is my htaccess config
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteCond %{REQUEST_METHOD} GET
RewriteRule .* static/%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I've just noticed you have ignore_query_strings: true
- it would need to be false otherwise all query strings are ignored, even the ones you've safe listed.
@ryanmitchell So there's no way to ignore all query string except a few that are listed in the config?
No, you can do that, but you have told it to ignore all query strings.
If you set that to false, then it will only keep the query strings you've specified in allowed_query_strings
@ryanmitchell I've changed my config to this:
'ignore_query_strings' => false,
'allowed_query_strings' => [
'audience', 'tag'
],
'disallowed_query_strings' => [
],
It keeps caching other query strings:
Yeah you're right - not sure why. I've opened a PR here with the changes needed: https://github.com/statamic/cms/pull/11143
@ryanmitchell Thanks a lot!!
Going to close it actually, just noticed this comment in the original PR: https://github.com/statamic/cms/pull/10701#issuecomment-2329319842
The allowed_query_strings
and disallowed_query_strings
config options aren't compatible with full-measure static caching due to the way Apache/Nginx rules work.
They're only compatible with half-measure static caching, as per the original PR (#10701):
Bug description
Hi, I would like to ignore query strings but allow some for filtering purposes. This is my config but it doesn't seem to work on the latest version of Statamic.
How to reproduce
When I go to these urls:
There's only one static file generated for
_blog.html
. But there should be a second one with_blog?audience=audience-name.html
because pages with the audience query string should be cached too.Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response