rails/actionpack-page_caching

caching for API that include parameters

dorijan opened this issue · 1 comments

Hi to all,
Is there a way to include params to generated cache?
for example that file would be called
somefile.json?param1=42&param2=1
Thank you
Dorijan

fxn commented

No, there isn't.

The main reason is that page caching stores files on disk so that web servers serve them directly if present. Web servers ignore query strings for static files, only the path is relevant, so the cache cannot distinguish.

When you need some extra logic, like cache that takes the query string into account, access control, Rack middleware, controller filters, etc., the next step is action caching.

Please take into account untrusted input, if that applies to your website. An attacker could fill your cache up just by generating query strings.