javascript - How do I set up gzip compression on a web server? -


i have embedded webserver has total of 2 megs of space on it. gzip files clients benefit, save space on server. read can gzip js file , save on server. tested on iis , didn't have luck @ all. need on every step of process make work?

this imagine like:

  1. gzip foo.js
  2. change link in html point foo.js.gz instead of .js
  3. add kind of header response?

thanks @ all.

-frew

edit: webserver can't on fly. it's not apache or iis; it's binary on zilog processor. know can compress streams; heard can compress files once , leave them compressed.

as others have mentioned mod_deflate you, guess need manually since embedded environment.

first of should leave name of file foo.js after gzip it.

you should not change in html files. since file still foo.js

in response header of (the gzipped) foo.js send header

content-encoding: gzip 

this should trick. client asks foo.js , receives content-encoding: gzip followed gzipped file, automatically ungzips before parsing.

of course assumes sure client understands gzip encoding, if not sure, should send gzipped data when request header contains

accept-encoding: gzip 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -