Different Rule Types in Requestly

Requestly is chrome and firefox extension which provides different rule types to modify request urls, modify headers, insert scripts etc. This article will explain the different rule types available in requestly and the different use cases for each rule type.

Different Rule Types in Requestly

There are currently 7 rule types available in Requestly :-

Redirect Rule

Redirect Rule is primarily used to redirect one url to another url. Example of common use cases could be:

  1. Test API version changes: Suppose there is a new version of some api which you are using. In order to test the backward compatibility of the api, you can just setup a redirect rule to redirect all urls from older version to newer version and check if your application breaks or not. This way, you don’t need to change singly line of your code and test the api upgrades.
  2. Fix Broken Urls, Redirect dead bookmarks, Create Url shortcuts: You can setup redirect rule to fix some broken rule, redirect the dead bookmarks to new working bookmarks and create url shortcuts.

There can be many more examples like these but above two examples give you an idea on where you can use Redirect Rule.

Cancel/Block Rule

Cancel Rule is primarily used for Blocking Requests therefore it is alternatively called as Blocker Rule as well. Primary use cases include:

  1. Blocking Websites — You can use Cancel Rule to block social media websites to stay focussed.
  2. Test your app when certain resource is not loaded — You can use Cancel rule to block a certain request which is not mandatary in your app and test how your app behaves without that resource.

Headers Rule

Headers Rule is used for modifying request and response headers. There are not many extensions available in Chrome Store and Firefox Store which allow you to modify response headers. Some use cases are:

  1. Bypass Iframe Buster Header: Most websites use X-Frame-Options header to prevent opening inside iframe. However, a developer may want to open the website inside iframe for debug/demo purposes. This article explains how you can do that using Header Rule.

You can setup Header rule to modify Request and Response headers according to your use cases. This rule is mostly used by developers and is the most used rule in Requestly as per Google Analytics. Have a look at list of headers not allowed for modification.

UserAgent Rule

UserAgent Rule is used to modify user agent on a given website and all the urls in that website. Internally, it just modifies the request header and overrides the navigator.userAgent at client side.

  1. Cross Browser Testing: UserAgent rule can be used to check how your website behaves when passed different user agents. For example :- You may have done browser specific coding based on user agent. You can use the rule to test that functionality instead of switching between browsers.
  2. Test Responsiveness of website: You can set user agent of mobile device and see how the website adapts to the user agent for the mobile device.

Script Rule

Script Rule is very handy and powerful. It allows you to inject custom scripts on a website. You can write custom code (Upto 500 characters) or use Requestly Library to host your code and use the url inside script rule. It also allows you to pick when should the script be executed before page load or after page load.

QueryParams Rule

QueryParams Rule, as the name suggests is used for modification of Query parameters in a request. You can perform these operations:

  • Add Parameter
  • Remove given parameter
  • Remove all parameters

QueryParams rule can be used to debug/test how the site behaves with different/unwanted query params. You can also use Query Params and apply random query parameter to each request and it will serve as cache buster.

Hope this article gives you a nice overview of power behind the simplicity in Requestly. Feel free to drop a comment if you have any questions. You can also reach out to us on requestly.extension@gmail.com for any extension related suggestions or feedback. We respond to each and every query from our users.