IIS doDynamicCompression and Browser Fallback - iis

I want to enable GZip compression on my controller actions using IIS's doDynamicCompression configuration option.
The question is what will happen if one of my users uses a browsers that doesnt support GZip - would IIS detect it and send it uncompressed?

When your users send request to the serveur, the Browser send a header Accept-Encoding.
This header specifies to the server with compresssions methods are accepted by the Browser.
For exemple "deflate,gzip", "gzip" or nothing.
IIS parses this Header to compress or not the response.

Related

set access-control-allow-origin response header only for static files in IIS

I'm using IIS to serve static files and also to send API requests to a python backend server.
for API requests the backend correctly sets CORS-related headers but for static files, I get errors. additionally, I can't set these in Response Headers in IIS because it conflicts with those set with the backend app.
So is there any way in IIS to check if some certain header is empty or requested response is a file or even check URI for a pattern like /static/ and then modify the response header?
I've reached to URLRewrite so far but I doubt it could modify the header.
after a little bit of digging it turned out you can set Response Header specific to each directory. so I set the CORS-related headers in my ./static/ sub-directories and it works fine.

"Accept-Language" header missing in http request from the browser

We have come across an issue in production logs where "Accept-Language" is missing in the http request from the browser. Although I am not able to replicate it so I want to understand any valid use case where any specific browser may send a request without "Accept-Language" header.
Even GET / HTTP/1.0 is a valid HTTP request. You can create one from the telnet client if you wish and it will still return a result from the server!
Accept-Language is a header to aid in content negotiation and is optional. The most widely used browsers send the correct headers, but there may be corporate proxies who may be filtering such headers. You should not rely on this header being present.

What happens if a browser doesn't support gzip?

I'm using mod_deflate to enable gzip on a site via the .htaccess file.
What happens if a browser that doesn't support gzip visits the site ?
Then the server doesn't send gzip. That's the whole point of the "Accept-Encoding:" heading from the browser, which indicates this by not having "gzip" in that header.

How can I check if Access-Control-Allow-Origin is enabled for my domain?

If I have configured Access-Control-Allow-Origin: http://mydomain correctly, should it be listed in the response headers if I view them using the web developer plugin? I don't see it. Should it be there?
I have tried viewing the response headers after submitting my post request, and just calling the page.
Background
I need to transfer a couple of values from mydomain to receivingdomain via XMLHttpRequest POST request and am trying to troubleshoot
XMLHttpRequest Page1.asp cannot load https://receivingdomain. No Access-Control-Allow-Origin header is present on the requested resource
If I turn on the Allow-Control-Allow-Extension plug-in my post requests work correctly. However, when this plug-in is disabled, my post requests are being received ok (the data is inserted into the database) - I'm just not getting any result back from the receiving server.

How do I cache control?

How do I get my website to save images to clients computer and use them, not redownload them every page reload?
I tried to send header("Cache-Control: max-age=3600"); but that had no effect.
You'll need to sand caching headers for the image files, not for your HTML document. You can use the header function only if the files are actually served by a PHP script - not if they are static files handled by the web server. If they are static files, check the documentation for your web server of choice.
Also consider sending en Expires header, and disable ETags.

Resources