How to find if a request is for js or css in httpHandler

264 views Asked by At

is there any way to find if a particular request is for JS or CSS in httphandler

to improve the performance of my website i was using HttpCompress from Code Project http://www.codeproject.com/KB/aspnet/httpcompression.aspx?msg=2544100

but since it is combining all the js it is breaking my javascript in many places...so i want to write a httphandler so that iwould be able to serve the js and css compressed.( i have already minified them using YUICompressor). i know this will cause multiple http request but in my case i have a deadline and so dont want combining of javascripts and css.

so any approach to do so???????

also i have seen in the source codes of compression module that they check if the file is already on the browser and send a 304 Not Modified response header but it is a little confusing to me so can anyone break it down as to how to proceed if i want to do the same....

i do not want whole answer just simple pointers would do...

thanks a lot

P.S i am on shared hosting and do not have access to IIS

1

There are 1 answers

0
Mike Buckbee On BEST ANSWER

In the example config file for HttpCompress they give two options for excluding files from being compressed: Exclusion by MIME type and Exclusion by path.

The following config file presumes that your server is serving javascript as text/javascript (something you should double check before setting).

<DCWeb>
<HttpCompress  compressionType="GZip">

  <IncludedMimeTypes>
    <add mime="text/html" />
  </IncludedMimeTypes>


  <ExcludedMimeTypes>
    <add mime="text/javascript" />
  </ExcludedMimeTypes>

   <ExcludedPaths>
     <add path="~/PathToYourJavascriptFiles/" />
   </ExcludedPaths>

  </HttpCompress>
 </DCWeb>