The Daraja HTTP Framework is a free open source library for Object Pascal (Free Pascal 3.0.4, Delphi 2009+), based on the stand-alone HTTP server component in Internet Direct (Indy). The 1.2.10 release contains a new method in the TdjWebComponent class, OnGetLastModified.

Caching support

WebComponents may override the new OnGetLastModified method to indicate the last change date of the resource. If a web client sends a HTTP request with a If-Modified-Since request header, the Daraja framework will check to see if the resource has been modified since the last time the client accessed the resource. If the answer is yes, the server returns a new copy of the resource to the client, if no, the server responds with a 304 Not Modified and the browser can retrieve the content from its cache.


The OnGetLastModified code in the example below returns the current local date without time:

function TCachedGetComponent.OnGetLastModified(Request: 
           TdjRequest): TDateTime;
  Result := Date;

This indicates that the resource has been last updated at 00:00 of the day. A client may use a cached copy of the resource, and will receive new resource content on the next day.

Unit test

The DUnit / FPCUnit test suite includes a test for the new feature in unit ConfigAPITests.


This feature is based on original code in TIdHTTPResponseInfo.SmartServeFile.

See also:

More information
– GitHub:
– API documentation:
– Resources:
– Wiki:


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s