I have a website that is hosted on an nginx server with gzip compression enabled. If I check my website on http://gzipwtf.com/, I see that only 2 files out of 7 are compressed. First I tought that maybe something is wrong with the filename/pattern, but I could not figure out why certain files are compressed and others not. There is no connection between file-type, filename, file-location and compression. It's not only js files or css files not working. Both types work.. but not for every file.
I have the following files:
css/sb.min.css (compressed)
css/style.min.css (not compressed)
css/jquery.mcustomscrollbar.min.css (not compressed)
js/jquery.mcustomscrollbar.concat.min.js (not compressed)
js/jquery.sidebar.min.js (not compressed)
js/jquery.min.js (not compressed)
js/sbhandlers.js (compressed)
I also checked in the DeveloperTools of Google Chrome. The Request Header was on each file like this:
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
...
But as to expect only the two compressed files had this in the Response Header:
Content-Encoding:gzip
I have absolutely no idea why only two files are compressed. I already wrote to the support of the webhoster, but he said everything is configured correctly.
Am I missing the point?!
Thanks for your help!
Related
I want to open files from S3 served by Nginx in a browser. Was unable to get it working with following config
Files in S3 buckets are text files with extension .manefiest
location /manefiest/ {
proxy_pass http://my-bucket.s3-website-us-west-2.amazonaws.com/;
types {
text/html manefiest;
text/plain manefiest;
}
}
I want browser to show the contents of the file. But with above config it was downloading the file.
Whats wrong here ?
Setting contentType:"text/plain" for uploaded file solved the problem.
Thanks #ofirule
When I'm running my app on localhost, I get 2 warnings concerning MIME type. This is one of them:
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3000/BootstrapEssentials/bootstrap.css".
The other warning is identical with a different file. Both files are in my working directory. So far, I have been to these similar questions but they haven't helped:
Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)
Chrome says "Resource interpreted as script but transferred with MIME type text/plain.", what gives?
Resource interpreted as stylesheet but transferred with MIME type text/html
Originally I was trying to use this line:
<link rel="stylesheet" href="/BootstrapEssentials/bootstrap.css">
I have since added in the type field:
<link rel="stylesheet" href="/BootstrapEssentials/bootstrap.css" type="text/css">
but that didn't do anything. I also have used the JavaScript Console to see that in the response header it has content-type: text/html; charset=utf-8 and I believe that if I can change that to being content-type: text/css; charset=utf-8 then everything will be fine but I can't find how to do that either.
As per the Meteor docs:
All files inside a top-level directory called public/ are served as-is to the client. When referencing these assets, do not include public/ in the URL, write the URL as if they were all in the top level. For example, reference public/bg.png as /bg.png. This is the best place for favicon.ico, robots.txt, and similar files.
Moving your stylesheets to a directory in public should do the trick!
I'm trying to scrape images this site:
http://mis.historiska.se/mis/sok/bild.asp?uid=336358&g=1
The site also have the option to download different sizes, like big image here:
http://catview.historiska.se/catview/media/highres/336358
I have no problem downloading manual, scraping the image, or even scraping the url, but the image and url is missing the image extension.
I need to scrape the full url with filename and extension., NOT the actual image.
The proper way to do this would be to check the headers after making a request to the given url for the filename and extension. A simple curl request to the given url gives me the following response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: image/jpeg
Content-Length: 569050
Date: Wed, 20 Jan 2016 15:33:49 GMT
The best way to guess the file extension would be to just check "Content-Type" header. Similarly, in order to get the filename, we'd be using the "Content-Disposition" header which need not necessarily be provided in the headers in which case we'll need to guess the filename from the URL.
A simple python snippet for guessing extension would be as follows:
import requests
import mimetypes
resp = requests.get(url)
content_type = resp.headers['content-type']
ext = mimetypes.guess_extension(content_type)
I'm looking for an open source project of an ISAPI filter for IIS6 to do gzip/deflate compression of HTTP requests like the "HttpZip" filter at http://www.port80software.com/products/httpzip/
IIS6 does compression natively. You'll need to be able to edit the IIS metabase so take care and make backups and also allow for downtime of sites.
These are the main sections in the metabase that control compression. You'll need to consider some of the flags depending on your setup, i.e.
Do you want to compress Dynamic and Static content of just Static. What level of compression do you want (I've gone for 9 rather than 10)? Which file types do you want to compress?
<IIsFilter Location ="/LM/W3SVC/Filters/Compression">
</IIsFilter>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/deflate"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="0"
HcDoDynamicCompression="FALSE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm
html
xml
css
txt
rdf
js"
HcOnDemandCompLevel="9"
HcPriority="1"
HcScriptFileExtensions="aspx
asp
asmx
asbx
ashx
axd
php"
>
</IIsCompressionScheme>
<IIsCompressionScheme Location ="/LM/W3SVC/Filters/Compression/gzip"
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="FALSE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="9"
HcFileExtensions="htm
html
xml
css
txt
rdf
js"
HcOnDemandCompLevel="9"
HcPriority="1"
HcScriptFileExtensions="aspx
asp
asmx
asbx
ashx
axd
php"
>
</IIsCompressionScheme>
<IIsCompressionSchemes Location ="/LM/W3SVC/Filters/Compression/Parameters"
HcCacheControlHeader="max-age=86400"
HcCompressionBufferSize="8192"
HcCompressionDirectory="%windir%\IIS Temporary Compressed Files"
HcDoDiskSpaceLimiting="FALSE"
HcDoDynamicCompression="FALSE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcExpiresHeader="Wed, 01 Jan 1997 12:00:00 GMT"
HcFilesDeletedPerDiskFree="256"
HcIoBufferSize="8192"
HcMaxDiskSpaceUsage="99614720"
HcMaxQueueLength="1000"
HcMinFileSizeForComp="1"
HcNoCompressionForHttp10="TRUE"
HcNoCompressionForProxies="TRUE"
HcNoCompressionForRange="FALSE"
HcSendCacheHeaders="FALSE"
>
</IIsCompressionSchemes>
Some helpful reference;
http://www.microsoft.com/technet/
http://weblogs.asp.net/owscott/
http://omaralzabir.com/
I have a gzip-compressed style and scripts in files:
/scripts.js.gz
/styles.css.gz
The problem is that it does not serve the correct mime-type and browser does not recognize, that the files are compressed css or js (browser recognize the type as application/octet-stream, where it should be text/css or so).
I tried adding the following to mime.type of nginx, but with no effect. I suppose, it does not recognize, that the file is compressed.
types {
text/css css.gz;
application/x-javascript js.gz;
}
When trying to access the files, the browser handle the files as files to download and not to present.
I had the same problem, coming from Apache.
The problem I found is, the types block does not allow you to specify .css.gz as a file extension. However, the location block does! My solution is to make a location for .css.gz and then modify the content type for .gz within that location, like this:
location ~ \.css\.gz$ {
add_header Content-Encoding gzip;
gzip off;
types {
text/css gz;
}
}
Do not change the mime types and use the Gzip Static Module to handle this.
When this is active, Nginx will try to serve "file.ext.gz" first and then try "file.ext", if not found, for all requests within the context (location etc) where it is active.