MAINTAINING CACHE CONSISTENCY FOR DYNAMIC WEB CONTENT
Technical Field
The present invention relates generally to electronic devices and more particularly to maintaining cache consistency for dynamic web content.
Background of the Invention
Many electronic commerce web sites provide a user with a "shopping cart." The shopping cart is the electronic equivalent of a conventional shopping cart that is used in a grocery store. A user places items that the user wishes to purchase in the shopping cart. When the user is done shopping, the user purchases the items in the shopping cart. This in analogous to passing through a checkout register in a conventional grocery store.
One of the difficulties with such shopping carts is that they contain dynamic data. The contents of the shopping cart change in response to user actions. For example, a user may add items to the shopping cart or may remove items from the shopping cart. Conventional systems have prohibited the caching of web pages that contain information regarding shopping carts. The problem is that there is no guarantee that if the web page is cached that the contents of the web page will be current. This prohibition may result in extensive added overhead that could be saved if such web pages were permitted to be cached.
Summary of the Invention
The present invention addresses the above-described limitation of conventional systems by enabling the caching of resources containing dynamic data where the dynamic data changes almost solely as a result of user action. In one embodiment of the present invention, the resources are web pages and the cache is maintained at a proxy between a client and a server. A selected web page containing dynamic data is cached and marked as valid. When the proxy becomes aware that the dynamic data for the
selected web page has changed as a result of user action, the web page is marked as invalid and updated by submitting a request for a new copy of the selected web page from the server.
The present invention may be particularly applicable to a web page that contains information regarding a shopping cart for a user. In such an instance, the web page is cached and valid until the user takes action to change the contents of the shopping cart. Upon the change of the contents of the shopping cart, the cached copy of the web page is marked as invalid and an updated copy of the web page is obtained that references the updated contents of the shopping cart.
In accordance with one aspect of the present invention, a method is practiced in a proxy that acts as an intermediary for a user and a server. A cache is provided for caching resources at the proxy, and a selected resource is provided in the cache. The selected resource contains dynamic data that changes in response to user action. When the dynamic data changes in response to user action, the selected resource stored in the cache is set as invalid, and a request is submitted to obtain an updated copy of the selected resource that contains updated dynamic data from the server. The selected resource may be a web page, a logical unit of video content, a logical unit of audio content or other type of resource.
In accordance with another aspect of the present invention, a method of keeping resources current in a cache is practiced in a device that includes a cache for caching resources from remote computing sites. A selected resource that contains dynamic data is stored within the cache. Information is provided regarding a dependency that identifies when the selected resource is to be marked as invalid and updated due to changes in the dynamic data resulting from user action. Communications between the user and a selected one of the remote computing sites are monitored to determine when the dynamic data in the selected resource has changed as a result of user action. The selected resource is invalidated when it is determined that the dynamic data in the selected resources have changed as a result of user action. The invalidation causes the selected resource in the cache to be updated. The device may be a computer system and
the method may be performed by a proxy. The selected resource may be, for example, a web page.
In accordance with a further aspect of the present invention, a method is practiced in a proxy that acts as an intermediary between a server and a client that is accessed by a user. In accordance with this method, a selected web page is provided that contains information regarding items in a shopping cart for a user. The selected web page is cached in the cache and, subsequently, it is determined that items in the shopping cart have changed. In response to determining that the items in the shopping cart have changed, an updated copy of the selected web page that contains current information regarding the items in the shopping cart is requested from the web server.
In accordance with a further aspect of the present invention, a proxy acts as a intermediary between the user and the server. The proxy includes a cache for caching resources. The cache holds a selected resource that contains dynamic data which changes in response to user action. The proxy also contains a cache manager for marking selected resources invalid and for submitting a request to obtain an updated copy of the selected resource from the server when the dynamic data changes due to user action. The selected resource may be a web page, for example.
Brief Description of the Drawings
An illustrative embodiment that is consistent with the principles of the present invention will be described below relative to the following drawings.
FIGURE 1 is a block diagram illustrating components that are suitable for practicing the illustrative embodiment.
FIGURE 2 provides a non-exhaustive list of suitable devices for practicing the illustrative embodiment.
FIGURE 3 provides a non-exhaustive list of resources that may be used in the illustrative embodiment.
FIGURE 4 is a flow chart that provides an overview of the steps performed in the illustrative embodiment.
FIGURE 5 A shows an example of a web page that allows an item to be added to a shopping cart.
FIGURE 5B shows an example of a web page that lists the items contained in the shopping cart.
FIGURE 6 is a flow chart illustrating the steps that are performed for a server to convey dependency information to a proxy.
FIGURE 7 is a flow chart illustrating the steps that are performed for a proxy to register a callback that is called when dynamic data for a resource changes due to user action.
FIGURE 8 is a flow chart that illustrates a case when a proxy monitors communications to identify dynamic data changes as a result of user action.
Detailed Description of the Invention
The illustrative embodiment facilitates the caching of resources that otherwise would be uncacheable. In the illustrative embodiment, a proxy situated between a client and a server caches resources. The cache may cache a resource that holds dynamic data that changes as a result of client action. The dependency information that identifies when the selected resource is to be invalidated and thus outdated is conveyed to the proxy. The server may convey this dependency information to the proxy or the proxy may already possess such knowledge. When the dynamic data changes as a result of client
action, the selected resource is invalidated and an updated copy of the selected resource is obtained from the server.
For purposes of the discussion below it is helpful to define a few terms.
A "web page" is a page of a document or a file that may be displayed by a web browser as a single page. Examples of a "web page" include a hypertext markup language (HTML) file and an extensible markup language file (XML) file. A web page may be encoded in other formats that are renderable by a web browser.
"Content" refers to any information or data that may be incorporated into a destination by a data sink. For example, content may be incorporated into a document, web page, a computer program or a database.
"Unit of content" refers to a logically distinct piece of content.
A "web server" refers to a computer system for providing at least one web page to a client.
A "resource" refers to a web page, program, data file or other entity that may be used or consumed by a client.
Figure 1 depicts an environment suitable for practicing the illustrative embodiment. A user 10 uses a client device 12 to communicate with a server device 14. A proxy 16 is situated between the client device 12 and the server device 14. The proxy 16 acts as an intermediary and may act on behalf of the client device 10 to request resources from the server device 14. The client device 12 includes a web browser 18, such as the Netscape Navigator web browser or the Netscape Communicator web browser. Those skilled in the art will appreciate that other types of web browsers may be utilized to practice the present invention. More generally, the present invention may be practiced with a program that uses the resource 24. The proxy 16 contains a cache 20 that caches resources 22. A cache manager 21 manages the cache and may be realized as a software
facility. The proxy 16 may ;xt as a content distributor in some embodiments for distributing highly demanded content from the cache 20 to the client device 18. The server device 14 holds a copy of a resource 24 that the user 10 desires. The server device 14 may be, for example, a web server that provides web pages to clients.
The client device 12, server device 14 and proxy 16 may be resident on a computer network, such as a local area network (LAN) or a wide area network (WAN). The client device 12, server device 13 and proxy 16 may be interconnected via an intranet, an extranet or the Internet, for example.
Those skilled in the art will appreciate that the client device 12 and the server device 14 may be any of a number of different types of devices. Figure 2 depicts a number of the different possible devices that may be used for client device 12 or for server device 14. The device may be a pager 28, such as a two-way pager that provides web access, a personal computer 30, a network computer 32, a personal digital assistant (PDA) 34 or a workstation 36. In addition, the devices 12 and 14 need not be conventional computer systems but rather may be set-top boxes 38 that interface with televisions or may be intelligent appliances 40 (i.e. electronic devices designed for household uses that have intelligence for communicating with other devices). Those skilled in the art will appreciate that the listing of devices in Figure 2 is intended to be merely illustrative and not exhaustive.
Those skilled in the art will appreciate that the resource 24 may take a number of different forms. As shown in Figure 3, the resource 24 may be a web page 50. The web page 50 may be, for instance, a hypertext mark-up language (HTML) document 60, an extensible mark-up language (XML) document 62 or other encoding format for encoding a web page. The resource 24 may also be a data file 52, a computer program 54, a logical unit of audio content 56 or a logical unit of video content 58. The list shown in Figure 3 is not intended to be exhaustive.
The operation of the illustrative embodiment will be described below relative to an instance wherein the resource is a web page. Figure 4 provides an overview of the steps
that are performed during operation of the illustrative embodiment to maintain cache consistency. Initially, a web page holding dynamic data is stored within the cache 20 at the proxy 16 (step 70 in Figure 4). For illustrative purposes, it is helpful to consider an exemplary case. Suppose that the web page contains information regarding the items in the shopping cart for a user. Figure 5B illustrates an example of a web page 94 that contains a list 98 of the items contained within the shopping cart. In many cases, a web page holds information regarding the total cost of purchasing the items in the shopping cart.
The dynamic data within the web page changes as a result of user action (step 72 in
Figure 4). With the shopping cart example, the data may change by the user adding an item to the shopping cart or moving an item from the shopping cart. Figure 5A shows an example of a web page 90 that allows the user 10 to add an item to a shopping cart. The web page 90 describes a yo-yo and contains a button 92 that, when activated, adds the item to the shopping cart. This web page 90 is displayed via web browser 18 to the user in order to facilitate such a selection. Figure 5B shows an example of how an item may be removed from the shopping cart. The user may manipulate the mouse cursor 97 to point at one of the three items in the list 98 of items to select the item and then activate the remove item button 96 to remove the item from the shopping cart.
The proxy 16 becomes aware of the change in the dynamic data (step 74 in Figure 4). The discussion below will detail various options that may be used for the proxy 16 to become aware of the change in dynamic data. The proxy 16 marks the web page as invalid (step 76 in Figure 4). This prevents the web page from being retrieved in response to request for the client device 12. In addition, the proxy 16 requests a new copy of the web page from the server device 14 (step 78 in Figure 4). The proxy 16 receives the new copy of the web page and stores this new copy of the web page in the cache 20 as a valid web page (step 80 in Figure 4). This approach assures that the web page containing dynamic data is cached and that a stale copy of the web page is not resident in the cache.
A server device 14 may convey dependency information to the proxy 16 (step 100 in Figure 6). For example, with the shopping cart, the server device 14 may advise the proxy 16 that the web page containing information regarding the shopping cart is valid until user action causes a change of the dynamic data. Those skilled in the art will appreciate that the present invention is more general than this particular instance. The present invention may be practiced with different varieties of resources, such as mentioned above. The present invention may specify dependencies that indicate when a cache resource is to be marked as invalid in response to user action. The proxy 16 uses the dependency information to determine when to invalidate resources 22 within the cache 20. The dependency information may be relayed for a single resource or for multiple resources.
The dependency information may be relayed in multiple ways to the proxy 16. For example, the information can be communicated out of band or may be incorporated into the web page. Where the web page is encoded in HTML, additional tags may be provided in the web page to communicate the dependency. Alternatively, this information may be encoded in the HREF tags which specify the uniform resource locator (URL) of a hyperlink target. In such a case the target may be a program, an applet or other module of code that acts to identify when dynamic data has changed.
The changing of the dynamic data as a result of user action may be conveyed a number of different ways. One option is for the system to employ callbacks. Figure 7 is a flow chart of the steps that are performed for such an instance. Additionally the proxy 16 registers a callback with the server device 14 (step 110 in Figure 7). The dynamic data in the selected resource changes due to user action (step 112 in Figure 7). As a result, the server calls the callback (step 114 in Figure 7). The callback may be a URL on the proxy 16 or may be another type of program that brings about the invalidation of the resource in which the dynamic data has changed.
Another option is for the proxy 16 to monitor communications and determine changes itself. Figure 8 is a flow chart illustrating the steps that are performed in such an instance. The proxy 16 monitors all communications between the user 10 and the
server device 14 (step 120 in Figure 8). The proxy 16 receives the communication that indicates that the dynamic data has changed as a result of user action (step 122 in Figure 8). The proxy 16 may then use this information to invalidate the resource and obtain an updated copy.
While the present invention has been described with reference to an illustrative embodiment thereof, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the intended scope of the present invention as defined in the appended claims.