cancel
Showing results for 
Search instead for 
Did you mean: 

HTML in ICM cache only available after several seconds

frank_stdle
Participant
0 Kudos

Hi,

I am using Thoms' solution of loading some HTML into the ICM cache with a temporary URL as described in this [thread|;

An IFrame in one of my WDA views refers to the cached URL. The HTML is cahed into ICM in the inbound plug when I enter the view containing the IFrame. This scheme works fine in our development system, but in our quality system I experience that it takes several seconds before the cached HTML is actually available from the ICM cache, so that the IFrame returns an "404 - Not found". If I enter the cached URL into my browser manually, I can see that after about 7-10 seconds it is available.

Is there some way to ensure that the cached HTML is available sooner? Alternatively, is there any way to check if a URL is alive from ABAP/web dynpro? Other suggestions are also welcome.

My best bet right now is to cache the HTML at an earlier stage, so that it hopefully is ready when it is needed.

Edited by: Frank Stødle on Apr 27, 2010 8:49 AM

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I've used this solution for quite a few years - dating back to BSP days where it was quite common to use the ICM cache as well. I've never experienced any delay in the population of the ICM cache. You might want to look into the core issue of why the ICM cache entry isn't available, as that doesn't seem right. This could be an indicator of something more serious.

frank_stdle
Participant
0 Kudos

Thank you for your reply, Thomas.

I wrote a small program to test the cache upload and then trying to access the URL -- I now discover that the URL is available on one server, but not on the other. Upon refreshing the page in the browser, I am alternatingly directed to one server (where the page is available) and then the other server (where the page is not available). Is there a way I can ensure that the HTML is cached on both servers, alternatively, can I make sure that I access only one server?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Have you tried changing the scope importing paramete rof the SERVER_CACHE_UPLOAD method to IHTTP_INV_GLOBAL? That should auto-force the propigation of the cache entry to all application servers. Control will not return to your application until the cache propigation is complete.

The other option would be to use an absolute URL instead of a relative one. This way you could build the absolute URL including the hostname and port of the current application server.

However it is odd that you hit this problem. You shouldn't be load ballancing between application servers within the same user session. Are you generating a cache URL and then passing it to a different user session?

frank_stdle
Participant
0 Kudos

I just tried supplying the scope parameter as IHTTP_INV_GLOBAL, and it certainly solved the problem in my test program - I am no able to access the URL all the time (meaning both servers).

I suppose that it is not so strange that load balancing occurs since I access the URL from my browser when testing, which would mean a separate user session for each access. From my WDA I accessed the URL from an Iframe element, and whenever I hit upon the correct server it worked, but usually I hit upon the server without the cached HTML.

Thanks a lot!

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>From my WDA I accessed the URL from an Iframe element, and whenever I hit upon the correct server it worked, but usually I hit upon the server without the cached HTML.

Are you building a relative or absolute URL for the iFrame? If it is a relative URL and yoru URL for your application points to the web dispatcher or message server then you are getting re-load balanced for the secondary request of the iFrame. This makes sense. If the pre-population of all ICM caches works for you, then great. Otherwise consider forcing a full url that points to your application server directly - of course then you might have authentication problems as your SSO ticket is probably only generated for the message server/web dispatcher hostname.

frank_stdle
Participant
0 Kudos

I am building a relative URL in the manner shown below (your code). The IFrame element also points to the relative URL.

I just tested my WDA, now setting the global parameter, and it works just fine.


****Create the cached response object that we will insert our content into
  data: cached_response type ref to if_http_response.
  create object cached_response
    type
      cl_http_response
    exporting
      add_c_msg        = 1.
*  cached_response->set_compression( options = cached_response->IF_HTTP_ENTITY~CO_COMPRESS_IN_ALL_CASES ).
  try. " ignore, if compression can not be switched on
      call method cached_response->set_compression
        exporting
          options = cached_response->co_compress_based_on_mime_type
        exceptions
          others  = 1.
    catch cx_root.
  endtry.
****set the data and the headers
  data: l_app_type type string.
 
      cached_response->set_cdata( lv_html_text ).
      l_app_type = 'text/html'.
 
 cached_response->set_header_field( name  = if_http_header_fields=>content_type
                                     value = l_app_type ).
 
  cached_response->set_status( code = 200 reason = 'OK' ).
  cached_response->server_cache_expire_rel( expires_rel = 60 ).
  data: guid type guid_32.
  call function 'GUID_CREATE'
    importing
      ev_guid_32 = guid.
  concatenate '/sap/public' '/' guid '.' 'html' into lv_iframe_url.
 
****Cache the URL
  cl_http_server=>server_cache_upload( url      = lv_iframe_url
                                       response = cached_response ).

Edited by: Frank Stødle on Apr 27, 2010 3:15 PM

Answers (0)