|
Expires is a Http header that allows you to define
when a resource (image, css, ...) will need to be reloaded. It is a
String representation of a Date in the format EEE, dd MMM yyyy HH:mm:ss z. There is lots of Java code available on the internet to produce the Expires header, the most part is similar to the following code I used during my experiments:
public static void setCacheExpireDate(HttpServletResponse response,
int seconds) {
if (response != null) {
Calendar cal = new GregorianCalendar();
cal.roll(Calendar.SECOND, seconds);
response.setHeader("Cache-Control", "PUBLIC, max-age=" + seconds + ", must-revalidate");
response.setHeader("Expires", htmlExpiresDateFormat().format(cal.getTime()));
}
}
public static DateFormat htmlExpiresDateFormat() {
DateFormat httpDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return httpDateFormat;
}
With the code, the browser started receiving headers like these:
Last-Modified: Sun, 19 Sep 2004 22:06:49 GMT
Cache-Control: PUBLIC, max-age=57600, must-revalidate
Expires: Thu, 09 Aug 2007 05:22:55 GMT
Content-Type: image/gif
Content-Length: 377
Date: Wed, 08 Aug 2007 13:22:55 GMT
Server: Apache-Coyote/1.1
It was supposed to be a simple configuration step of my website optimization, but - after trying different values for the headers, including Expires header, Cache-Control and Last-Modified - the YSlow was still saying the Expires header was not
present. I got confused and started to navigate on discussions lists and
blogs when I finally figured out the problem: YSlow uses the idea of
a far future.
A far future Expires header
Well, far future seems to be one of that relatives measures,
when for a butterfly it could be 23 hours and for a mountain it could
be one million years. So, I suppose the far notion should be
pre-defined some way. I didn't find and I confess didn't search too
much about the standard values adopted by YSlow, but from my desktop
experiences I found it: The YSlow magic number far future is
172801 seconds = 48 hours + 1 second
That's it, everything more than two days seems to be far enough to YSlow - a minor detail in this complex task of websites tunning. And it is not an official information, just an empirical observation. If you need more precise guidance about YSlow, the Chief Performance Yahoo!, Steve Souders, is launching a book entirely dedicated to website optimization - a promising publishing from a company that serves millions of users every day :) A last and very important advise: don't take decisions based only on YSlow. It is just an indicator, a tool created for Yahoo site optimization that can give you a glimpse about the quality of your web site - a helpful tool that should evolve from now on to become part of the arsenal of tips and tricks for websites tunning.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Yes, very nice tool.
The RFC does not require to send Expires header on 304 responses unless the Expires header value actually changed. YSlow seems to honor that even though there is no Expires header on the 304 response. May be it only considers non 304 responses for the 3rd item.
Does it honor Cache-Control:max-age alternative to Expires?
Posted by: ksenji on August 08, 2007 at 07:41 PM
-
The subject of a very wonderful and distinct
I thank you for continuing excellence
Thank you
=========================================================================
ليبيا
شباب ليبيا
libya
منتديات
منتديات ليبية
غرائب وحقائق
أحاديث شريفة
برامج اسلامية للجوال
مفاتيح الديجيتل
الشيرنج
الرسيفرات
كتب إسلامية
خلفيات للموبيل
الشعر الشعبي
الصحة والطب
طب اسنان
كتب طب اسنان مجانية
برامج طبية
تعلم الإنكليزية
اللغة الفرنسية
طب الإعشاب
الخواطرالادبية
الازياء والمكياج
تعليم الطبخ
الاثاث الحديث
مقاطع كرة قدم
المصارعه الحرة
اهداف كوره
الفوتوشوب
اروع البرامج
الدوري الليبي
خلفيات رياضية
المصارعة
كورة عربية
كرة قدم عالمية
الدوري الإيطالي
الدوري الاسباني
الدوري الإنجليزي
صور المشاهير
انواع الحلويات
افلام كوميدية
احدث الافلام
افلام
التقنية
تحميل افلام
برامج
اخر برامج الجوال
kaspersky
أفلام كرتون عربية
برامج برامج كمبيوتر
برامج حماية
برامج اختراق
برامج صوت
برامج تحميل برامج احدث البرامج
محادثة
خلفيات الطبيعة
برامج مبايل للتحميل
اخبار الفن
احدث الافلام للتحميل
تحميل افلام رعب
ترجمةأفلام
الكامات
برامج جوال
برامج محاسبة
برامج
kasper
games
برامج
برامج
انترنت
برامج صوتية
شبكات الحاسوب
خلفيات للويندوز
تطويرالمواقع
العاب
العاب الفيديو
games
شفرات
برامج مسنجر
خلفيات شاشة
صور ترحيبيه
الفوتوشوب
خلفيات طبيعة
تطويرالمواقع
الفوتوشوب
مقاطع البلوتوت
مسجات ليبية
خلفيات
الفلاش
التصميم الثلاثي
برامج الجوال
العاب الجوال
فيديو كليب
مسجات
ترددات ستالايت
نغمات
Posted by: libyan on May 30, 2008 at 02:15 PM
|