I am setting this in C# with this line:
WebOperationContext.Current.OutgoingResponse.Headers.Add(HttpResponseHeader.Expires, DateTime.Now.AddSeconds(10).ToString());
Now I know the format is off on this as it expects the following: Tue, 06 Dec 2011 20:24:15 GMT
Is there a class in .NET implementing IFormatProvider
I could leverage here? Or will I need to create my own?
Expires Headers are certain lines of code that tell your browser how long it should keep the cached files from your site. You can add Expires Headers by adding a code such as ExpiresByType image/jpg “access plus 1 month” to your site.
When you set an expires header for a resource, such as all jpeg images, the browser will store those resources in its cache. The next time the visitor comes back to the page it will load faster, as the browser will already have those images available.
The Last-Modified response HTTP header contains a date and time when the origin server believes the resource was last modified. It is used as a validator to determine if the resource is the same as the previously stored one. Less accurate than an ETag header, it is a fallback mechanism.
The Date property represents the value of a Date HTTP header on an HTTP response. The Date header is the date and time the message was sent. Javascript and . NET languages do not use the DateTime object directly.
I use DateTime.UtcNow.AddDays(30).ToString("R")
From MSDN:
The "R" or "r" standard format specifier represents a custom date and time format string that is defined by the DateTimeFormatInfo.RFC1123Pattern property. The pattern reflects a defined standard, and the property is read-only. Therefore, it is always the same, regardless of the culture used or the format provider supplied. The custom format string is "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'". When this standard format specifier is used, the formatting or parsing operation always uses the invariant culture
You can use the Custom Date and Time Format Strings.
Tue, 06 Dec 2011 20:24:15 GMT
generate the above format like so:
DateTime.Now.AddDays(30).ToUniversalTime()
.ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With