Set Custom Response Header for Specific Files on IIS 7.5 and Apache2


In IIS you can enable Static and Dynamic Compression that provides almost everything for you. In this case, the IIS compress files itself and send proper headers.

But if you have pre-compressed files, e.g., done by Webpack, it does not send proper response headers and a web browser raises an error, e.g., “Unexpected character…”. The problem is that Content-Encoding: gzip response header is not sent by the IIS and the browser does not know that the response file should be decoded.


A solution is to update web.config for these files so the IIS will add a specific header for these files via the rewrite rule.

Example for IIS 7.5

In this example, IIS will add Content-Encoding: gzip header to every file with the .js.gz extension. See  outboundRules section.

<?xml version="1.0" encoding="UTF-8"?>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<rule name="Set custom HTTP response header">
<match serverVariable="RESPONSE_Content_Encoding" pattern=".*" />
<add input="{REQUEST_URI}" pattern="\.js\.gz$" />
<action type="Rewrite" value="gzip"/>

Example for Apache2

The same for Apache2 server. See filesMatch section.

<VirtualHost *:5080 >

DocumentRoot /var/www/site

<Directory /var/www/site>
Require all granted
RewriteEngine on # Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L] # Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]

<filesMatch "(\.js\.gz)$">
Header set Content-Encoding "gzip"
ErrorLog /var/log/apache2/site_error.log
CustomLog /var/log/apache2/site.log

Windows 10 Update 1607 & Bitlocker & TPM is Not Working

I have been waiting for final Windows 10 Anniversary Update (1607) for a long time. There are plenty of new features. The update was available immediately so there was no reason to wait with the installation. It took about 40 minutes on Lenovo X1 Carbon 20A7 and there were no problems during the installation, just like a regular update.

But then I enabled a new feature Windows Subsystem for Linux aka “Shell on Windows”. But after the restart a BitLocker key was required because it was not possible to load stored key from TPM. Ok, it can happen. So I set the (very long) key, and … a black screen. So I have restarted the PC and a system errors (0xc0000001, 0xc210000) occurred.

So I created a bootable USB and run a system recovery from the last recovery point (before enabling the Linux subsystem). After a restart there was no error. Ok. I though it was some problem during the feature activation. So I Enabled the feature again and, wait for it, the problem occurred again. So I made the restore again. NOTE: There is no evidence that it is caused by the feature activation.

While looking for the problem, I found that there can be some problem with the BitLocker here and here. So I tried to suspend the encryption. But after restart I had to restore the system again :/.

Ok, so I decided for the last option – disable disk encryption. If it will not help, I will have to reinstall the system. So after a few minutes of waiting BitLocker was disabled and there was no problem after the restart. Yes! So now, let’s enable BitLocker again.

But it told me it is not possible because there was some problem with TPM (Figure 1). Again: What?

Figure 1

There are some articles about changes in security in Windows 10 Anniversary Update. But it should not be related to this problem.

So I updated BIOS to the last version (1.25 – 08.04.2016).  Then I tried to enable BitLocker again, but there was still the same error. even I tried to set TPM to 2.0 in BIOS.

Finally I found a thread on (and a related one). It seems that there are some compatibility issues. But it is still in investigation process and I (We) have to wait for the solution.

EDIT 16.8.2016: It seems that Windows guys have found the problem, suggested some temporary fixes. The problem should be fixed in the next update on 23.8.2016.