Uploaded image for project: 'Railo'
  1. Railo
  2. RAILO-2379

CFCACHE doesn't honor KEY attribute used with ID attribute

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.0.4.001
    • Fix Version/s: None
    • Labels:
    • Steps to Reproduce:
      Hide

      Execute this CFML for the same application but under two different hosts.

      <cfset myCacheKey = replace( CGI.HTTP_HOST, '.', '_', 'all' )>
      <cfset cacheTestHTML = "">
      
      <cfcache key="#myCacheKey#" action="put" id="prime" value="">
      
      <cfcache key="#myCacheKey#" action="get" id="cacheTest" name="cacheTestHTML">
      <cfif isNull( cacheTestHTML )>
          <cfsavecontent variable="cacheTestHTML">
              <p>My cachekey is: <cfoutput>#myCacheKey#</cfoutput></p>
          </cfsavecontent>
          <cfcache key="#myCacheKey#" action="put" id="cacheTest" value="#cacheTestHTML#" timespan="#CreateTimeSpan( 0, 0, 10, 0 )#">
      </cfif>
      <cfoutput>#cacheTestHTML#</cfoutput>
      <p>It should be: <cfoutput>#replace( CGI.HTTP_HOST, '.', '_', 'all' )#</cfoutput></p>
      
      Show
      Execute this CFML for the same application but under two different hosts. <cfset myCacheKey = replace( CGI.HTTP_HOST, '.' , '_' , 'all' )> <cfset cacheTestHTML = ""> <cfcache key= "#myCacheKey#" action= "put" id= "prime" value=""> <cfcache key= "#myCacheKey#" action= "get" id= "cacheTest" name= "cacheTestHTML" > <cfif isNull( cacheTestHTML )> <cfsavecontent variable= "cacheTestHTML" > <p> My cachekey is: <cfoutput> #myCacheKey# </cfoutput> </p> </cfsavecontent> <cfcache key= "#myCacheKey#" action= "put" id= "cacheTest" value= "#cacheTestHTML#" timespan= "#CreateTimeSpan( 0, 0, 10, 0 )#" > </cfif> <cfoutput> #cacheTestHTML# </cfoutput> <p> It should be: <cfoutput> #replace( CGI.HTTP_HOST, '.' , '_' , 'all' )# </cfoutput> </p>

      Description

      When caching HTML with CFCACHE, Railo doesn't appear to honor the KEY attribute used with the ID attribute. Instead, it only looks up the ID attribute, which produces incorrect results when the same IDs are used despite different KEYs.

      Say you have one application accessible by two different hosts. The different hosts have different data, with the CFML using the CGI.HTTP_HOST value to look up the appropriate settings.

      The application makes liberal use of CFCACHE tag. Here's an example:

      <cfset myCacheKey = replace( CGI.HTTP_HOST, '.', '_', 'all' )>
      <cfcache key="#myCacheKey#" action="put" id="prime" value="">
      

      In Adobe ColdFusion, the cfcache KEY attribute allows your application to separate items with the same ID attribute. Railo seems to ignore the KEY attribute when setting the ID attribute, which means whichever site cached that ID first wins.

      Here's a full page example. By setting up two hosts to look at the same page, and by refreshing them each, you'll find that one of the hosts displays the cached data from the other.

      <cfset myCacheKey = replace( CGI.HTTP_HOST, '.', '_', 'all' )>
      <cfset cacheTestHTML = "">
      
      <cfcache key="#myCacheKey#" action="put" id="prime" value="">
      
      <cfcache key="#myCacheKey#" action="get" id="cacheTest" name="cacheTestHTML">
      <cfif isNull( cacheTestHTML )>
          <cfsavecontent variable="cacheTestHTML">
              <p>My cachekey is: <cfoutput>#myCacheKey#</cfoutput></p>
          </cfsavecontent>
          <cfcache key="#myCacheKey#" action="put" id="cacheTest" value="#cacheTestHTML#" timespan="#CreateTimeSpan( 0, 0, 10, 0 )#">
      </cfif>
      <cfoutput>#cacheTestHTML#</cfoutput>
      <p>It should be: <cfoutput>#replace( CGI.HTTP_HOST, '.', '_', 'all' )#</cfoutput></p>
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                micstriit Michael Offner
                Reporter:
                awayken Miles Rausch
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: