This module will make your ajax-enabled Views, use GET instead of POST.

Why?
Because GET is much better for caching. If you're using something like Varnish, or Boost, these will not store POST requests.

Views uses the Drupal Ajax framework. This by default uses POST.
While a lot of Ajax inside of Drupal requires POST (the Views admin UI, for example), a view itself doesn't. If you disable Ajax on a View, it will use GET anyway.

How?
This module overrides a core Drupal Ajax JavaScript function (this is sometimes referred to as monkey-patching).

Note
To ensure an Ajax request does not contain any duplicate HTML IDs, CSS and JS files. The Drupal Ajax framework sends through the name of every HTML ID, CSS and JS file in the POST Ajax request (allowing duplicates to be stripped out from the Ajax response).
Due to the size this makes the request, this is not possible when using GET, so this module removes them from the GET request.
Although we have not yet seen this cause any issues, it is something you should be aware of when using this module.
If you do come across any issues because of this, you can set a particular View to be exempt from using GET, by going to admin/config/system/views_get_ajax (this is opt-out as opposed to opt-in).

@See #956186: Allow AJAX to use GET requests which is an issue to fix this in core, while still retaining all the current functionality.

Also, if you are using Varnish with the Four Kitchens VCL, or something similar, you will need to remove the following line from vcl_recv
req.url ~ "^.*/ajax/.*$" ||
Otherwise, Varnish will not cache the Views Ajax responses.

Drupal 8

Setup instructions

  • Once this module is enabled, enable the Views ajax get display extender (/admin/structure/views/settings/advanced)
  • Enable on each view by editing the "Use AJAX" setting, and enabling GET.

There is also a known incompatibility with other modules that modify the views ajax url, e.g. views ajax history. See #2913388: Disable URL replacement on GET requests in Drupal.Ajax.prototype.beforeSend

Project information

Downloads