开发者

serve zipped javascript file

开发者 https://www.devze.com 2023-01-27 03:14 出处:网络
I join all my external javascript files into one file. I make开发者_StackOverflow社区 two version of this file. One is zipped, one is not. How to check the browser support gzip or not and serving a ri

I join all my external javascript files into one file. I make开发者_StackOverflow社区 two version of this file. One is zipped, one is not. How to check the browser support gzip or not and serving a right file? And if browser support gzip, how to tell it this is a zipped file?


Is not required to zip JavaScript file,
instead, you should use mod_deflate

Apache will handle the compression and detect clients browser support gzip header.
If the clients browser support the gzip header, a compressed copy of JavaScript will be sent.

You can also explicitly set an expiration header for static files to better leverage on browser cache.


Normally when your browser requests a page, it sends information on the content types/encodings it can accept, including (if applicable) whether it can accept gzipped content. So, you can check the header (I think it's the Accept-encoding header) to see if it has gzip in it.

Though, I'm pretty sure that the server handles this (checking for compression support and compressing files) itself if you set it up correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消