Jaa


Refreshing Caches for an Address Resource

If you have to provide custom cache refresh behavior for your application (address resource), you have two choices:

  • You can hook into the CacheRefresh event that is raised by the SiteCacheRefresh.axd HTTP handler in your Commerce Server 2009 Web site. To do this, subscribe to the CacheRefresh event on the SiteCacheRefresh class. Your event handler will be passed all the request parameters from the HttpContext.

  • You can implement your own HTTP handler mapped to the SiteCacheRefresh.axd URI, as described in this topic. By default, this is configured to map to the SiteCacheRefresh HTTP handler class in the Microsoft.CommerceServer.Runtime namespace.

Ensuring That Your Application Receives Cache Refresh Notifications

If your address resource complies with a small set of requirements, it will be able to participate in cache refresh operations. These operations are initiated centrally and will start your custom cache refresh code on each Web server on which the application that corresponds to your address resource is deployed. The following list shows these requirements:

  • Your address resource must not be a Web service according to the bit settings in the basic property f_ResourceFlags. In other words, it must have bit &H00000008 set (indicating that it is an address resource). It must not have bit &H00000400 set (indicating that it is a Web service).

  • The extended property s_WebServerMachine must be initialized with one or more Web server names. Each specified Web server will receive a cache refresh request.

  • The extended property f_EnableHTTPS must be initialized with an integer that can be interpreted as a Boolean value, where zero (0) equals False and non-zero values are interpreted as True. This setting will control whether SSL (https://) will be used when it makes the cache refresh requests.

  • The extended property s_VirtualRootName must be set to either:

    • The slash ("/") character to indicate that your address resource does not have a virtual root.

    • The virtual root name without any leading or trailing slash ("/") character.

  • The extended property s_IPPort must be set to a non-null value that specifies one or more ports for each Web server specified by the extended property s_WebServerMachine. If multiple ports are specified for a given Web server, they should be separated by pairs of dollar sign ($) characters.

  • Your address resource must have an HTTP handler named SiteCacheRefresh.axd that is designed to handle the cache refresh requests. This handler will be passed a URL parameter named CacheToRefresh that will be set to one of several standard values, and which your handler may opt to use.

If your address resource property settings and the corresponding Web application complies with these requirements, it can participate in cache refresh operations. When you start a cache refresh operation for a particular named cache X, a Web request will be sent to URLs built from these property values according to the following scheme:

http[s]://<s_WebServerMachine>:<first s_IPPort value, or 80>/[s_VirtualRootName/]SiteCacheRefresh.axd?CacheToRefresh=X

Additional explanation:

  • The URLs will start with "http://" or "https://" based on the setting of the extended property f_EnableHTTPS.

  • The number of values of the extended property s_WebServerMachine will determine the number of URLs generated and therefore the number of Web requests sent.

  • The algorithm will try to find and use the first port number that is specified for each Web server, but will otherwise use port 80.

  • Your address resource may have a virtual root specified.

  • The name of the HTTP handler you supply is fixed as "SiteCacheRefresh.axd".

  • The parameter to the HTTP handler "SiteCacheRefresh.axd" is fixed as CacheToRefresh.

  • The parameter value assigned to the parameter CacheToRefresh comes from the following set of standard values:

    • CommerceCaches

    • AllCaches

    • CatalogCache

    • SiteTermCache

    • AllMarketingCaches

    • ProfileCache

    • ProfileCache.<list of primary keys, separated by periods ".">.<profile type>

See Also

Other Resources

Creating an Instance of an Address Resource

Working with Address Resources