How to disable caching for only internet explorer 8 on WordPress?

I’m loading different HTML and CSS for explorer 6-8 with following code:

<?php 
$IE6 = (ereg('MSIE 6',$_SERVER['HTTP_USER_AGENT'])) ? true : false;
$IE7 = (ereg('MSIE 7',$_SERVER['HTTP_USER_AGENT'])) ? true : false;
$IE8 = (ereg('MSIE 8',$_SERVER['HTTP_USER_AGENT'])) ? true : false;
if (($IE6 == 1) || ($IE7 == 1) || ($IE8 == 1)) {
    // some code
}
 ?> 

and it works fine until i turn on caching with plugin Wp-rocket.
This plugin simply adds some code in .htaccess file.

Read More

I added this code: RewriteCond %{HTTP_USER_AGENT} !(MSIE [6-8]) [NC] in .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} on
RewriteRule .* - [E=WPR_SSL:-https]
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* - [E=WPR_SSL:-https]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=WPR_ENC:_gzip]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{QUERY_STRING} =""
RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC]
RewriteCond %{REQUEST_URI} !^(.*/feed/)$ [NC]

#my code
RewriteCond %{HTTP_USER_AGENT} !(MSIE [6-8]) [NC]

RewriteCond %{HTTP_USER_AGENT} !^(facebookexternalhit).* [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" -f
RewriteRule .* "/wp-content/cache/wp-rocket/%{HTTP_HOST}%{REQUEST_URI}/index%{ENV:WPR_SSL}.html%{ENV:WPR_ENC}" [L]
</IfModule>

but it doesn’t work.

so, is there any way to turn off caching for only explorer 6-8?

Related posts