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.
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; begin Result := Date; end;
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.
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.
– GitHub: https://github.com/michaelJustin/daraja-framework
– API documentation: https://michaeljustin.github.io/daraja-framework/
– Resources: https://www.habarisoft.com/daraja_framework.html
– Wiki: https://github.com/michaelJustin/daraja-framework/wiki