Open HadiAbbasi opened 2 years ago
But even if the ETag is automatically generated you will need to check if it's valid or not and return 304 Not Modified
if appropriate.
This will require that you know the algorithm used to generate ETag since as far as I know there is no standard way, it's up to you.
I think it's much cleaner to implement yours, may be like this:
std::string getEtag(const std::string &source); // Your own standard way to generate ETag from string representation of responses (e.g. file content, json as string)
bool isCacheValid(const drogon::HttpRequestPtr &req, const std::string ¤tETag); // Is the request's `If-None-Match` Header matches the ETag of the string representation of the response you are about to return
void sendCachedResponse(const drogon::HttpRequestPtr &req, const Json::Value &jsonResponse, const std::function<void(const drogon::HttpResponsePtr &)> &callback, const std::string &cacheControl = "no-cache, private")
Hi
why there is no any auto etag set for file response in drogon? when I load and send back a new file using newFileResponse, there is no any etag set in response headers! so I'm trying to set it by myself using MD5 hash!