Search code examples
dartrikulo

How do you uncache the home page in Rikulo Stream server?


Could you tell me how can I uncache the default home page in Rikulo Stream? By home page I mean the main domain (xxx.xxx.com) with no sub path (/xxx), not even including '/'. The urimapping setting doesn't allow me to set a filter for a path that not start with '/', '.', '[' or '(' and (.*) is not working for me, (cache-control is still set to max-age=2592000 for the default home page).


Solution

  • Is it a static page (e.g., index.html) or a RSP page?

    If it is RSP, you can specify the header(s) you like. For example,

    [:header
      Cache-Control="no-cache, must-revalidate, no-store, private, max-stale=0, max-age=0, post-check=0, pre-check=0"
      Expires="0" Pragma="no-cache"]
    

    If it is static, there is no direct way to override max-age, ETAG, and related headers. But, there is a few alternatives. First, you can implement your own resource loader).

    Second, you implement a handler to set the header and include the real page. Assume you mapped HTML files under /s:

    uriMapping: {
      r"/s/.*\.html": (HttpConnect connect) {
        connect.response.headers..contentType = "text/html"
          ..add("Cache-Control", "no-cache"); //also other headers
        return connect.include(connect.request.uri.path.substring(2));
      }
    
    • If a page is included, it won't update the headers.

    Of course, you can implement your HTML file in RSP. Then, you got the total control. Plus, you can use the script tag to generate a proper link easily (which includes a simple version control).