Tuesday, November 03, 2009

How to setup custom metadata or http headers for Amazon S3 objects in CrossFTP?

If you are using Amazon S3 to serve your files over http, you will get an additional flexibility to custom http headers could provide.  For instance if you properly set Cache-Control http header, it will help you to reduce your Amazon S3 bills.
You can set up http-headers for the files already located in S3 buckets. Just select the file you want to set headers for and right click it. Choose Properties... from the context menu, and you will see the Metadata table in the Advanced tab



The content of the metadata Table shows the headers metadata that are already assigned to the file. Most of them are assigned by Amazon S3 by default.

If you want to add a custom http header metadata, just click + button and type a name/value pair for the header.
 Click ok and the new header will appear in the Metadata Table. Click Commit, and the header will be applied to the file on S3. Next time someone requests this file from the web browser, the new http header will take effect. 

Can I set headers for multiple files at once?

Yes. Just multi-select the files that you want to set headers for and follow the instructions above. If you want to apply for the subfolders as well, toggle the option "Apply changes to subfolders".

Commonly Used HTTP Headers for Cache:


  • Expires:
      Key: "Expires" 
      Value: HTTP-date
An example of its use is
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Note: if a response includes a Cache-Control field with the max-
      age directive (see section 14.9.3), that directive overrides the
      Expires field.
  • Cache-Control:
    Key: "Cache-Control" 
    Value: cache-directive
cache-directive = cache-request-directive
         | cache-response-directive
cache-request-directive =
           "no-cache"                          ; Section 14.9.1
         | "no-store"                          ; Section 14.9.2
         | "max-age" "=" delta-seconds         ; Section 14.9.3, 14.9.4
         | "max-stale" [ "=" delta-seconds ]   ; Section 14.9.3
         | "min-fresh" "=" delta-seconds       ; Section 14.9.3
         | "no-transform"                      ; Section 14.9.5
         | "only-if-cached"                    ; Section 14.9.4
         | cache-extension                     ; Section 14.9.6
cache-response-directive =
           "public"                               ; Section 14.9.1
         | "private" [ "=" <"> 1#field-name <"> ] ; Section 14.9.1
         | "no-cache" [ "=" <"> 1#field-name <"> ]; Section 14.9.1
         | "no-store"                             ; Section 14.9.2
         | "no-transform"                         ; Section 14.9.5
         | "must-revalidate"                      ; Section 14.9.4
         | "proxy-revalidate"                     ; Section 14.9.4
         | "max-age" "=" delta-seconds            ; Section 14.9.3
         | "s-maxage" "=" delta-seconds           ; Section 14.9.3
         | cache-extension                        ; Section 14.9.6
cache-extension = token [ "=" ( token | quoted-string ) ]

Conclusion

With the ability to set custom http headers CrossFTP Pro is becoming a compelling tool for Amazon S3 users, in particular to web site developers who want to have granular control on how the files are handled by web browser. The more important thing is that, caching can significantly lower your Amazon S3's monthly bills.
--
CrossFTP is a FTP, SFTP, FXP, WebDav, Amazon S3, Amazon Glacier and Google Cloud Storage client for Windows, Mac, and Linux.
CrossFTP Team
http://www.crossftp.com/

No comments: