Skip to main content
HttpResponseHeaderCollection.Age | age property

Gets or sets the TimeSpan object that represents the value of an Age HTTP header on an HTTP response.


var age = httpResponseHeaderCollection.age;
httpResponseHeaderCollection.age = age;

public Nullable<TimeSpan> Age { get; set; }

Public Property Age As Nullable(Of TimeSpan)

property IReference<TimeSpan>^ Age { 
   IReference<TimeSpan>^ get();
   void set (IReference<TimeSpan>^ value);

Property value

Type: IReference<TimeSpan> [JavaScript/C++] | System.Nullable<TimeSpan> [.NET]

The object that represents the value of an Age HTTP header on an HTTP response. A null value means that the header is absent.


The Age property represents the value of he Age header on an HTTP response. The Age header is the age of the entity in the cache.

When programming with .NET, this structure is hidden and developers should use the System.TimeSpan structure. The value can be null, because it's typed as TimeSpan? (a nullable TimeSpan).

In JavaScript, this structure is accessed as a value, not as an object. For example, use var a = 10000, not var a = { duration: 10000 }.

Note  In JavaScript, this structure is treated as the number of millisecond intervals, not the number of 100-nanosecond intervals. Therefore, Windows.Foundation.TimeSpan values can lose precision when being ported between languages.

For more detailed information, see the Windows.Foundation.TimeSpan interface.

The following sample code shows a method to set the Age header on an HttpResponseMessage object using the Age property on the HttpResponseHeaderCollection object.

    public void DemonstrateHeaderResponseAge() {
        var response = new HttpResponseMessage();

        // Set the header with a strong type.
        DateTimeOffset value = DateTimeOffset.UtcNow;
        response.Headers.Age = new TimeSpan(1, 35, 55); // 1 hour, 35 minutes, 55 seconds.

        // Get the strong type out
        System.Diagnostics.Debug.WriteLine("Age value in minutes: {0}", response.Headers.Age.Value.TotalMinutes);

        // The ToString() is useful for diagnostics, too.
        System.Diagnostics.Debug.WriteLine("The Age ToString() results: {0}", response.Headers.Age.ToString());

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Web::Http::Headers [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


Windows::Web::Http::Headers [C++]



See also