1

I notice that the Craft admin pages append random query parameters to their static files, i.e. jquery-2.2.1.min.js?x=AKVKl03So:

example network data from admin, showing query parameters

This prevents those static files being cached in browsers, which can make the admin views unreliable in less-than-optimal network conditions.

I see the logic to make this happen is in Craft's app/helpers/UrlHelper.php

Is there a sane way to deactivate that behavior, and allow browsers to cache Craft's static files?

1 Answer 1

2

I don't think it's a great idea to disable this cache busting; they put it in there for a reason. However, if you really need/want to do it, instead of modifying Craft, I'd just configure Apache/Nginx to discard the query string for paths that match /admin/resources/

https://wiki.apache.org/httpd/RewriteQueryString

2
  • Thanks! That would do the job, but I agree that it's probably not a great idea - future changes to static files won't appear in users' browsers because of the caching. What I'd really love is a way to trigger that $dateParam logic for all the static files, so that they deterministic ?d= query parameters instead of random ?x= query parameters, thus getting both browser-side caching and also graceful cache invalidation when updates happen. Commented Aug 22, 2016 at 17:54
  • 1
    If you're going through the trouble of dropping the query string, theoretically you could setup how far out the cache should be on the admin side as well, say an hour or 2 depending on how long your authors are in the site for. Commented Aug 23, 2016 at 5:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.