Biz-mark/Quicksilver

Query String Support

Closed this issue · 5 comments

Hello!

I love this plugin (I left a nice review on the marketplace)

I wondered if you have considered adding logic to support query strings?

I understand that the current aim for the plugin is to speed up fairly static sites, which this does brilliantly, but I feel that API driven sites would benefit here, too.

This is something I need, but obviously it's quite a demand as it deviates from the intention of the base package. I will fork and work on this for my own needs, but I would like to hear your thoughts on whether its something you'd be interested in merging in the future.

Cheers!

Hi! Thanks for your review!

Try this configuration instead one in docs and let me know if it resolved your problem with query strings:

##
## Serve Cached Page If Available
##
RewriteCond %{QUERY_STRING} ^(.)
RewriteCond %{REQUEST_URI} !(.+)\.(png|jpg|jpeg|gif|js|css|json|mp3|mp4|mov|ogv|ogg|ico|woff|ttf)$ [NC]
RewriteRule !^index.php index.php [L,NC]
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/storage/page-cache/pc__index__pc.html -f
RewriteRule .? /storage/page-cache/pc__index__pc.html [L]
RewriteCond %{DOCUMENT_ROOT}/storage/page-cache%{REQUEST_URI}.html -f
RewriteRule . /storage/page-cache%{REQUEST_URI}.html [L]
RewriteCond %{HTTP:X-Requested-With} XMLHttpRequest
RewriteRule !^index.php index.php [L,NC]

Thanks for this, but it's not a problem with the rewrites (actually I use nginx anyway) but a feature enhancement I am looking for.

The original laravel package does not support caching with query strings as files are only saved by path and file/slug which is fine, but I would like to enable the caching of each file along with variants generated according to the passed parameters - Biggest perceived difficulty is matching the correct file I think.

This is obviously a lot more complicated and it might be difficult to implement but I would like to tackle the problem anyway as file caching gives such a massive performance boost.

Hope this makes sense!

The original laravel package does not support caching with query strings as files are only saved by path and file/slug which is fine, but I would like to enable the caching of each file along with variants generated according to the passed parameters - Biggest perceived difficulty is matching the correct file I think.

I had similar idea, and actually I tried to make it real, but that same code worked with apache server but not with nginx, so i dropped it. If you want, you can try to make it and submit PR.

Will do.

I have it working (needs some testing before I push to my fork) for Nginx. Should be alright for Apache, too.

I have also added support for json, rss, xml and txt files by uri explicit extension or response content-type header all with query string support but requires changes to how files are saved (and will therefore need adjustments to cache clearing etc.)

My file format is $uri[q_$args].$extension

and the corresponding nginx location block is

try_files $uri $uri/ \
       /storage/page-cache/${uri}[q_${args}].html \
       /storage/page-cache/${uri}[q_${args}].json \
       /storage/page-cache/${uri}[q_${args}].rss \
       /storage/page-cache/${uri}[q_${args}].xml \
       /storage/page-cache/${uri}[q_${args}].txt \
       /index.php?$query_string;
}

I'll push something later, but just an update on progress.

Conversation moved to PR #16