17.07.2015 Views

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

The Art of SQL Server FILESTREAM - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 12: Planning, Configuration and Best PracticesAdd a content-type column on <strong>FILESTREAM</strong> tablesIf you intend to serve the <strong>FILESTREAM</strong> data from a web application, it may be beneficialto store the appropriate MIME type on each row. When the web application serves the<strong>FILESTREAM</strong> data to the client, it can set the appropriate content type in the HTTPResponse header. Based on the content type, the client browser/application can open thefile using the appropriate application.In most cases, if you have a column that stores the file extension or file type, you canbuild the content type (such as "application/msword" for Word documents, "image/jpeg"for jpeg images, and so on). But if you deal with a large number <strong>of</strong> different file types, itmay be a good idea to store the MIME type <strong>of</strong> the BLOB value stored in each row.Add a timestamp or date column to track lastmodified date for cache controlIf you are serving <strong>FILESTREAM</strong> data from web applications, caching is an importantfactor to consider. When a client browser and web server communicate over HTTPprotocol, they exchange some caching information. <strong>The</strong> client tells the server about thecopy <strong>of</strong> the file locally available (local cache) and the server instructs the client to use thelocal copy or to download a new copy <strong>of</strong> the file.If the web server tells the client that the file on the server is the same as the copy thatthe client has in the local cache, the file is not downloaded again. Instead, the clientbrowser serves it from the local cache. This significantly enhances the performance <strong>of</strong>web applications.Caching information is exchanged between the client browser/application and web serverusing the HTTP cache headers. <strong>The</strong> client browser sends the time stamp or etag <strong>of</strong>the file it has in the local cache. After examining the cache header information <strong>of</strong> the454

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!