Skip to Content

This blog is written based on Fiori on-premise ( ABAP webserver used as gateway server ).

You might have observed for js resource request, there are different types of status response, 200 OK or 304 Not Modified.

/wp-content/uploads/2016/04/clipboard1_934976.png

We can use the following three scenarios to illustrate the difference.

Scenario1: the js file is accessed for the first time. No client or server side cache exists

Paste the following url into your Chrome and you could observe the http request below:

https://<host>:7080/sap/bc/ui5_ui5/ui2/ushell/resources/~20160308134900~/sap/fiori/core-min-0.js

You could see an HTTP 200 OK status code.

Where do the below highlighted HTTP response headers come from? How are they filled by server?

/wp-content/uploads/2016/04/clipboard2_934977.png

You can debug the following method in gateway server to get the answer.

1. line 9, the server tries to extract “last-modified” field from HTTP request which is not existing since this is the first request, so lv_modified_since is initial.

/wp-content/uploads/2016/04/clipboard3_934978.png

2. In my server, the last modified timestamp of JavaScript file core-min-0.js is 20160316205045, so variable lv_change_time_char and lv_change_time_string are filled accordingly.

/wp-content/uploads/2016/04/clipboard4_934982.png

3. Line 20 explains the reason how the first highlighted HTTP response field is filled.

/wp-content/uploads/2016/04/clipboard5_934983.png

4. The following two screenshots explain the logic where and how the left highlighted HTTP response fields are filled.

/wp-content/uploads/2016/04/clipboard6_934984.png

/wp-content/uploads/2016/04/clipboard7_934985.png

Scenario2: do not close the Chrome opened in scenario1, but directly click F5 to refresh

This time, instead of HTTP 200 OK, you get an HTTP 304 Not modified response:

/wp-content/uploads/2016/04/clipboard8_934986.png

Since you didn’t close Chrome after you test scenario1, the cookie is reused and the more important point is the last modified timestamp returned by scenario1 as HTTP RESPONSE field is now used as the HTTP REQUEST field.

/wp-content/uploads/2016/04/clipboard9_934987.png

This time, server can successfully parsed this “If-Modified-Since” from HTTP request field. Please compare the screenshot below with the second screenshot of this blog.

/wp-content/uploads/2016/04/clipboard10_934988.png

Since now the last modified timestamp passed by Chrome is equal to the one got from server side, so HTTP 304 Not modified response field is set accordingly.

/wp-content/uploads/2016/04/clipboard11_934989.png

Scenario3: Close Chrome and reopen it

This time the core-min-0.js is directly retrieved from browser cache, since no “if-Modified-since” is appended in HTTP request field.

However, as you see the “last-modified” field is set in HTTP response field, so if you don’t close Chrome and directly press F5, you will then again observe the HTTP 304 Not Modified response, just due to the same reason in scenario2.

/wp-content/uploads/2016/04/clipboard12_934990.png

/wp-content/uploads/2016/04/clipboard13_934991.png

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply