Forum Discussion

Swordfish_11740's avatar
Swordfish_11740
Icon for Nimbostratus rankNimbostratus
Feb 18, 2013

Compression Filtering Using iRules

Hi All,

 

My company has clients all round the world. Some would benefit from level 9 compression whereas others that are within europe benefit more from level 1 -least compression.

 

Is there a way to create multiple http profiles with different levels of compression and create iRules to filter them into different profiles deplending on where they are?

 

Kind Regards.

 

 

Swordfish

 

9 Replies

  • Hey Ben,

     

     

    I don't think you can switch HTTP profiles using an iRule, however, you can modify the compression level using the COMPRESS::gzip command. Details here: https://devcentral.f5.com/wiki/iRules.COMPRESS__gzip.ashx. Even if you use deflate, this setting should apply to that too, not that it's obvious.

     

     

    How do you plan on differentiating between client geographies?
  • Hi Steve,

     

     

    Thank you for yout time.

     

    Thats great stuff, gzip is my choosen method, Is there some way of geogroupong. e.g - if (geogroup)=Asia compress:gzip level 6 - if (geogroup)=Europe compress:gzip level 1.

     

    I have run a fair amount of tests revealing that more compression actually slows the reponse time to those around Euroope but outside of europe benfit more from level 6.

     

    Any ideas?

     

     

    Kind Regards,

     

     

    Ben
  • You can use the whereis Command, details here: https://devcentral.f5.com/wiki/iRules.whereis.ashx. For details of other continent codes, just Google 'ISO continent code'.

     

     

    Here's an example;

     

     

     when HTTP_RESPONSE { if { [whereis [IP::client_addr] continent] eq "EU" } { COMPRESS::gzip level 1 } else { COMPRESS::gzip level 6 } } 

     

     

    I'm UK based too so feel free to hook up on Linkedin if you think it might be useful.

     

  • Hi Steve,

     

    This is great, thank you very much I will have a play with it.

     

    Kind Regards,

     

     

    Ben Thomas

     

  • You're welcome. If you get stuck post back. FYI, I got a list of the continent codes for everyone's reference (I'm not sure why but Oceania still sounds to me like something from a Barbie film!);

     

     

    •AF – Africa

     

    •AN – Antarctica

     

    •AS – Asia

     

    •OC – Oceania (includes Australia and New Zealand)

     

    •EU – Europe

     

    •NA – North America

     

    •SA – South America
  • haha it does!

     

     

    I have tried t implement this as an irule, but I get an error:

     

    01070151:3: Rule Compression_iRule error: line 2: command is not valid in current event context (HTTP_REQUEST) FORMATTER ERROR (":" and "&" not supported in Page Names)

     

     

    This is with the irule in its simplest form:

     

    when HTTP_REQUEST { COMPRESS::gzip level 3 }

     

     

    I get the same thing when I try to wrap it in a geolocation-aware rule too:

     

    when HTTP_REQUEST { if { FORMATTER ERROR (":" and "&" not supported in Page Names) continent] eq "EU" } { COMPRESS::gzip level 1 } else { COMPRESS::gzip level 6} }

     

     

    Any ideas? Has this been deprecated in a later release of LTM (currently running 10.2.2)

     

     

    Thanks, Ben
  • OK, despite the wiki saying it's supported in HTTP_REQUEST, I could only get it to work with v11.3 in HTTP_RESPONSE which makes a certain kind of sense.

     

     

    I'm not sure this will help considering the error message but can you try changing the event and post back if it's still an issue please.