• Post Reply Bookmark Topic Watch Topic
  • New Topic

multiple http calls

 
pandu chinnu
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I avoid making multiple HTTP calls for content that hasn't changed?
 
Jesus Angeles
Ranch Hand
Posts: 2069
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript may help. Bring to frontend, business logic that you can do so, without destroying your design.

Sometimes, duplicate logic can exist; first is in javascript, and second in the server. In this case, the javascript is only to solve issues like yours.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browser does that for you already. If the content is tagged with the appropriate response headers (Last-Modified, Cache-Control, Expires), then the browser will not fetch the content again in the specified time frame. Instead, the cached version will be used.

The browser may also send the request, but include the appropriate If-Modified-Since header, which will cause the server to not send the content again if it is still valid, but instead to reply with a 304 Not Modified response.

Instead of trying to put your own solution in top of that, work with what HTTP can do (and browsers already implement).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!