Solved

gzip js not displaying in headers?

Posted on 2013-12-09
6
299 Views
Last Modified: 2013-12-09
Hi,

I'm trying to see if my javascript files are zipped and being sent properly by the server. I checked in the Chrome Developer Tools (see attached files) to see snapshots of my headers for the a javascript file.

I have this in my .htaccess file:

# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP

AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT}
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]

Open in new window


I think I'm being redundant for the sections but I'm just checking to see if any of the code works. It doesn't seem like it. Am I missing something?

Thanks
Screenshot-2013-12-09-08.53.16.png
0
Comment
Question by:Victor Kimura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 39706705
You are missing several things.  First is the fact that like I said on your other question, 'gzip' method is negotitated between the browser and the server.  Second is that you have already fetched that file and you are getting a 304 result code which means that the server does not have a newer version so the browser should use the copy that is in the browser cache.  

That also means that no data was transferred.  So even if it was originally 'gzipped', you won't see it in those headers because no data was transferred.  Do a Ctrl-F5 refresh of the page to tell the browser to get completely new copies of the files.  Since the javascript is not fetched with the initial request but is fetched after the main page loads, you may have to load the JS file directly in the browser to get it to update instead of showing a 304 code.
0
 

Author Comment

by:Victor Kimura
ID: 39706742
For some reason, this doesn't work:
 <script type="text/javascript" src="./controller/06_sixth_page-12_09_13_0754.js.gz"></script>

But the minified and the regular js file works fine. I'm just testing here to see if the manual gzipped file works or not. Is there something wrong with it?

The gzipped file is much smaller than the regular file. So why wouldn't the server send the gzipped version?
0
 

Author Comment

by:Victor Kimura
ID: 39706779
Is there a way I can see if the server is sending the gzipped version or the non-gzipped version with firebug or Chrome developer tools?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39706809
Not that I know of.  You might be able to see it in the response header if the file is large enough.  If it is a small file, it won't be gzipped anyway.

You are continuing to talk as though the 'gzip' method is your choice.  It is Not.  It is negotiated between the browser and the server and it is essentially transparent to you.  The 'gzip' method of sending a response is at a different 'layer' in the communication between the browser and the server and it's not one that you can choose.  It is intended to operate automatically to send you the file you have requested.

When you link to a '*.gz' file, that's what the server would send instead of a '*.js' file.  But the browser can't use a '*.gz' sent that way when it is supposed to be a javascript file.  If the '*.gz' file was large enough, it might get 'gzipped' itself in the background.
0
 

Author Comment

by:Victor Kimura
ID: 39706833
Oh, ok. I get it. I thought I could even manually change it but since it works  on a different 'layer' then I get it now. Yes, makes sense. I was also trying to see what the server was sending - the .gz or the regular file. There should be a way to debug if the gzip is working properly or not though for specific js files or even css files.

Thanks for the help, Dave. That's helpful.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39707077
You're welcome.  I think something is telling people they can 'speed up' their web sites by 'Gzipping' their content.  Unfortunately, it fails to tell them that it is not under their control.  In addition, small files don't get gzipped because it takes more time to gzip them that than it does to simply send them.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSS: Forcing Tables Where the Width is Greater than 1000px to Behave Like Width: 100% 8 47
Worldmap 1 28
Debugging Html 8 31
ASP sending two datas 2 23
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question