Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP headers: Last-Modified - how can it mimimize server load?

Imagine the following use case:

I use an AJAX request for getting some info about Item and use this URL: http://domain/items/show/1

In my database all items have a field called modified_at where we store the moment when this item was previously modified.

How can Last-Modified server HTTP header in response can minimize load/reduce requests/increase responsiveness if we need to process this request every time on the server side? It looks like we don't reduce the number of HTTP requests with that response and we don't reduce the load on server.

Who needs this anyway?

Am I right, that it's used mostly for the purpose of saving bandwidth?

like image 407
user80805 Avatar asked Oct 14 '22 05:10

user80805


1 Answers

The purpose is to save bandwidth, not on your server but on the client. Uncachable AJAX requests will likely make the UI incredibly slow for your visitors, not having to transfer data over and over again drastically improves performance in the client's browser.

If you want to reduce the number of reqs you should set an explicit Expires header on the response. The client won't request the resource until the time set by Expires has run out.

like image 143
Martin Avatar answered Dec 18 '22 13:12

Martin