Cache JSON response

Hi,
I used following blog to Ajaxify a component
http://blogs.adobe.com/mtg/2011/11/building-components-in-adobe-cq5-part-2-a-tutorial-on-j query-ajax-and-sling.html
Basically this talks about creating a JSP file in conponent with name [ComponentName].json.POST.jsp to allow running custom code to return JSON.
My component is doing JCR search based a parameters and returning a JSON list (which could be different for different parameters)
So all went well till I discover performance issues with AJAX response time.
Is there a way in CQ5 to cache result of JSON and have it auto every x mins?
Thanks in adavnce.

Thanks Justin. I have couple of questions to understand the proposed solution
1) Do you know how can I convert component POST to GET (for the reference blog). I tried renaming to myajaxsample.json.GET.jsp but it breaks component input dialog. Note that this component is making Ajax call to
<%= currentNode.getPath() %>.json
2) Can I force cache to update for cases when data for a particular JSON request is updated?

Similar Messages

  • How to fix a problem with the order of strings in a JSON response for a CFHTTP request?

    Good morning, guys! (It's 10:50 a.m. in Brazil)
    First of all, I'm still new at CF and my questions may seem too much silly and my English's not the best, so, please be patient with me. hehe
    Well, I'm accessing a link via CFHTTP that gives me a JSON response. I'm not familiar with JSON yet, so I'm working it as a string and using string functions (Find,RemoveChars,Replace,etc), but it happens to me that I'm receiving a certain kind of order of the strings list from the JSON when I access it directly from the browser and other kind of order totally different when I access it from the CFHTTP.
    I only figured it out because I was working at home with my code and there everything went just fine as expected. Then I brought to my job to develop a little bit more as soon as I get a free time and here my code doesn't work anymore. When I took a look at the JSON by a CFOUTPUT, I realized the strings were in a different order.
    Does anyone know why is it happening?
    Link to the JSON: http://sigmine.dnpm.gov.br/ArcGIS/rest/services/extra/dados_dnpm/MapServer/0/query?text=83 0620/2012&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelInter sects&where=&returnGeometry=true&outSR=&outFields=FID,Shape,PROCESSO,ID,NUMERO,ANO,AREA_HA ,FASE,ULT_EVENTO,NOME,SUBS,USO,UF&f=pjson
    Basic code simplified to find out that the order of strings were coming different when access by CFHTTP:
    <cfhttp url="#URLAbove#" method="get" result="DadosDoDNPM" charset="utf-8" timeout="10000" />
    <cfset DadosJSON = deserializeJSON(DadosDoDNPM.FileContent) />
    <cfif arrayLen(DadosJSON.features)>
        <cfset CodigoFonteJSON = ToString(serialize(DadosJSON.features)) />   
        <cfoutput> #CodigoFonteJSON# </cfoutput>
    </cfif>
    Is there a way to fix it and to make my code work everywhere?
    If it matters, I use Railo at home and at my job.
    Since now, I thank you.

    When you deserialize JSON data, ColdFusion converts it into native structures and arrays (roughly equivalent to JavaScript objects and arrays).  In ColdFusion, structures are unordered (that is, they don't maintain keys in any particular ordered sequence).
    This really shouldn't be a problem though, at least not if you just want to work with the data contained in the deserialized JSON structure.  So DadosJSON should be a native ColdFusion structure, and you can interact with it like any other structure in ColdFusion.  In fact, you should not have to re-serialize it at all unless you need to send it to an external application using JSON.
    Why are you reserializing the data?  And why use serialize() instead of serializeJSON()?
    -Carl V.

  • MVC Web API json response truncated?

    I have an MVC 4 Web API in C# hosted in IIS 7
    Basically this service has a queue that has items enqueued every minute. I expose a GET method that allows for all the items in the queue to be returned in a json array.
    the queue is really this: Queue<List<CustomObject>> mQueue; then every minute a new list is enqueued.
    The max size of the queue is 50 (1 hour of data)
    the maximum count of a list in said queue is ~500 and minimum count is ~100. When I debug the api locally It will return all the elemnets in the queue no problem. only takes a couple seconds. The size of the json response (saved to disk) is ~10Mb.
    So I decided to host this service on a VM. I let it run for a while so the queue gets populated. then I make my request:
    http://somepoint:4328/AzureQueueService?view=Full
    I only get 1.30 - 1.32 mb of data back. Which equates to about 4 minutes worth of data! So the question becomes is there some setting in IIS that forces the response sent to be less than 2Mb? Maybe there is a similar setting in my webconfig? Or maybe IIS
    has created more than one instance of my service? Either way, I'm missing something here.

    What OS (including SP number) your service is running on? (both local and VM)
    Do you receive the same amount of data as specified in Content-Length header? Is your response a valid JSON (just having less data than expected), or it is really truncated?
    Where is your queue hosted? Is it just a static object inside IIS process, or somewhere out-of-process?
    How is it filled? By another method passing incoming data? Do you use thread synchronization when accessing the queue?
    IIS may have multiple worker processes per application, and each will have its own static queue (of course, if it is hosted in-process). Also IIS might recycle worker processes, so in-process data could be lost.

  • How to remove 'd' wrapper from odata json response ?

    Hello,
    from example request :
    /sap/opu/odata/sap/ZQM_CONFIRMATION_SRV/Check_batch_and_cust?$format=json&WERK='ASJV'&PDATUM=''&CHARGE='140005'&MENGE=''&VORG=''
    response json looks like this:
    {"d":{"__metadata":{"id":"http://x:8000/sap/opu/odata/sap/ZQM_CONFIRMATION_SRV/CHECK_BATCH_AND_CUSTOMERSet(Charge='',Menge='',Pdatum='',Vorg='',Werk='')","uri":"http://x:8000/sap/opu/odata/sap/ZQM_CONFIRMATION_SRV/CHECK_BATCH_AND_CUSTOMERSet(Charge='',Menge='',Pdatum='',Vorg='',Werk='')","type":"ZQM_CONFIRMATION_SRV.CHECK_BATCH_AND_CUSTOMER"},"Charge":"","Menge":"","Pdatum":"","Vorg":"","Werk":"","Msg":"OK","Name1":"WIN-Warth GmbH","Name2":"","Status":"0"}}
    I want to remove wrapper 'd'
    Any ideas ?
    regards
    Lucas

    Hello Lukasz,
    In my openion your json response will always be encapsulated in a standard structure/format as u have shared. I do not see any way u can remove ' d ' from the json response in GW level
    Regards,
    Ashwin

  • Create dynamic controls from JSON Response

    I have a requirement to create a group of checkbox with lebels in a page from JSON response.
    The JSON response is
        "data": [
                "CodeStatus": "Red"
                "CodeStatus": "Orange"
                "CodeStatus": "Green"
                "CodeStatus": "Yellow"
    the  design is:
    the box is vertically scrollable, as it can have more color codes.
    Can anyone suggest how to design the above?
    If one can provide the implemantation code, that would be very good as I have very time to implement it.

    Have a look at templates and for more complex scenarios factory functions, which give you the ability to dynamically create controls from model data.
    SAPUI5 SDK - Demo Kit
    Regards,
    Jason

  • Want a JSON response by the Bing Synonyms API

    Hello,
    How do I request for a JSON response from the synonyms API. I could not find the answer in the documentation found here: https://onedrive.live.com/view.aspx?resid=23DD320B9FC9364A!113&app=Word&authkey=!AAxXlP949CZOQyA
    I decided to try query param format=json and it did not work, neither did it work if I passed in the Content-Type: application/json
    Everytime the API sends back the response in XML.
    Please let me know,
    AJ

    What I could get from the documentation is basically:
    A request to the HTTP endpoint consists of an HTTP GET request to the appropriate URI. There are two
    URIs, one for XML results and one for JSON results. These are http://api.bing.com/xml.aspx and
    http://api.bing.net/json.aspx, respectively.
    Now the synonyms API URL is: 
    https://api.datamarket.azure.com/Bing/Synonyms/GetSynonyms?Query=%27word%27
    what I am supposed to do here?

  • Problem in SXI Cache refresh:Response Code 503

    Hi all,
    The SXI cache contents are not getting refreshed automatically on making changes in the Directory or Repository. Also, I am unable to refresh the cache contents manually in transaction SXI_CACHE.
    I get the following error on refreshing: Response Code 503: Service Unavailable.
    The RFC Destination INTEGRATION_DIRECTORY_HMI has correct entry in the URL(Path Prefix) and Test Connection from SM59 is working fine.
    How do I make this work?
    Regards,
    Puloma Chaudhuri.

    Hi all,
    The exact nature of the error on refreshing in SXI_CACHE is:
    CacheRefreshRepositoryCommunicationException: Attempt to access application <b>REPOSITORY</b> using Http Method Invocation (<b>HMI</b>) failed. Detailed information: <b>Invoking ROA method "ReadObjects"</b> via HMI ... FAILED due to following exception: Message: Connection to system REPOSITORY using application REPOSITORY lost. Detailed information: Error accessing "http://server:50000/rep/remoteobjectaccess/int?container=ejb" with user "<b>XIDIRUSER</b>". Response code is 503, response message is "Service Unavailable"
    Does that narrow it down?
    Regards,
    Puloma Chaudhuri.

  • Q: WLS 7 Cache Filters (Response Caching) Keys, Vars?

              I can't seem to find any better docs about setting up cache filters than this
              http://edocs.bea.com/wls/docs70/servlet/progtasks.html#response_caching
              specifically, what are some examples of the init params, Keys and Vars?
              - especially in use with Servlets.
              Can Keys be Attribute names? Parameter names? Headers? Cookies? Other?
              And then what are examples of Vars?
              "variables calculated by the page that you want to cache"
              Does that really mean, it's cacheing a variable, like a resultset calculated in
              the doGet, instead of the page (response)? If so what can those be? Or should
              that have said "variables used to calculate the page"?
              Let's say I have a Servlet which might be called like
              myservlet?param1=A&param2=B&param3=C
              and there are a few cookies, cookie1=X;cookie2=Y;cookie3=Z
              In this case, only param1, param2, cookie1 can actually make a difference in the
              response. So I want my cached keyed off those (and only those).
              what would it look like?
              <init-param>
              <param-name>Key</param-name>
              <param-value>?</param-value>
              </init-param>
              <init-param>
              <param-name>Vars</param-name>
              <param-value>?</param-value>
              </init-param>
              

    We are in process of updating the docs for cache filter. So they should be
              in
              better shape soon. Sorry for the inconvenience.
              Here is an example:
              <filter>
              <filter-name>CacheFilter</filter-name>
              <filter-class>weblogic.cache.filter.CacheFilter</filter-class>
              <init-param>
              <param-name>scope</param-name>
              <param-value>session</param-value>
              </init-param>
              <init-param>
              <param-name>timeout</param-name>
              <param-value>30m</param-value>
              </init-param>
              <init-param>
              <param-name>size</param-name>
              <param-value>10</param-value>
              </init-param>
              <init-param>
              <param-name>key</param-name>
              <param-value>parameter.userid,parameter.clientip</param-value>
              </init-param>
              <init-param>
              <param-name>vars</param-name>
              <param-value>request.var1,request.var2,request.var3</param-value>
              </init-param>
              </filter>
              <filter-mapping>
              <filter-name>CacheFilter</filter-name>
              <url-pattern>/cached/*</url-pattern>
              </filter-mapping>
              Various scopes:
              parameter -> request parameter
              request -> request attribute
              requestHeader -> request header
              responseHeader -> response header
              session -> http session
              application -> context
              cluster -> cluster scope (need to configure cluster listener for this)
              key:
              Syntax: Comma separated list of <scope>.<attribute name>
              Typically a given cache is identified by it's cache name that you configured
              in web.xml.
              If that's not specified the request uri is used as a cache name. But using
              keys you can
              specify additional values to identify a tag. For example if you want to
              separate out the
              cache for a given end user, then in addition to the cache name you can
              specify the keys
              as the userid, values for which you want to pick it up from the request
              parameter scope
              (query param/post params) plus perhaps a client ip. So you will specify your
              keys as:
              "parameter.userid,parameter.clientip"
              Here "parameter" is the scope (request parameter scope) and
              "userid"/"clientip" are the parameters/attributes.
              This means the primary key for the cache becomes the cache name (request uri
              in this
              case) + value of userid request param + value of clientip request param.
              Note: If you don't specify the scope the cache system will search all the
              scopes
              for the attribute.
              size:
              For caches that use keys, the size element defines the number of entries
              allowed.
              The default is an unlimited cache of keys. With a limited number of keys the
              tag
              uses a least-used system to order the cache (BubblingCache).
              vars:
              Same syntax as the key:
              Syntax: Comma separated list of <scope>.<attribute name>
              Variables are used to do input caching. So you can save the variables you
              used to calculate the cache. When the cache is retrieved the variables are
              restored back to the scope you specified. For example for retrieving results
              from
              a database you used var1 from request param, var2 from session etc. So
              when the cache is created the value of these variables are stored with the
              cache. When the cache is accessed next time these values are restored
              so you will be able to access them from respective scopes. For example
              var1 will be available from request and var2 from session.
              Hope this helps.
              --Vinod.
              "Stek" <[email protected]> wrote in message
              news:[email protected]...
              >
              > I can't seem to find any better docs about setting up cache filters than
              this
              >
              > http://edocs.bea.com/wls/docs70/servlet/progtasks.html#response_caching
              >
              > specifically, what are some examples of the init params, Keys and Vars?
              > - especially in use with Servlets.
              >
              > Can Keys be Attribute names? Parameter names? Headers? Cookies? Other?
              >
              > And then what are examples of Vars?
              > "variables calculated by the page that you want to cache"
              > Does that really mean, it's cacheing a variable, like a resultset
              calculated in
              > the doGet, instead of the page (response)? If so what can those be? Or
              should
              > that have said "variables used to calculate the page"?
              >
              > Let's say I have a Servlet which might be called like
              > myservlet?param1=A&param2=B&param3=C
              > and there are a few cookies, cookie1=X;cookie2=Y;cookie3=Z
              >
              > In this case, only param1, param2, cookie1 can actually make a difference
              in the
              > response. So I want my cached keyed off those (and only those).
              >
              > what would it look like?
              >
              > <init-param>
              > <param-name>Key</param-name>
              > <param-value>?</param-value>
              > </init-param>
              > <init-param>
              > <param-name>Vars</param-name>
              > <param-value>?</param-value>
              > </init-param>
              >
              

  • How to cache json files with dispatcher?

    Our project is unique in that we want to cache particular json files. Our performance will rely on it. However it seems dispatcher is only capable of caching HTML. This will be real bad news for us if it's impossible.
    In our /cache configuration, we'd like to do:
    /rules
      /0000
        /glob "*.html"
        /type "allow"
      /0001
        /glob "*.docache.json"
        /type "allow"
    Unfortunately, after requesting the json file through the dispatcher, the file is not cached at all, even if doing /glob "*" /type "allow"

    Depends what you mean by clear out. Dispatcher does two things on activation request: invalidate and evict.
    Invalidation:
    find the /invalidate section of your dispatcher.any and add :
    /0001
                /glob "*.json"
                /type "allow"
    Obviously you'll need to change the numeric ID of the rule from 0001 to whatever makes sense for you.
    Eviction (deletion):
    If /mypath/mypage is being activated, then only files meeting globbing pattern /mypath/mypage.* will be deleted, such as /mypath/mypage.html and /mypath/mypage.json... however, child directories WILL NOT be evicted, such as /mypath/mypage/jcr_content/parsys/mycomponent.json
    Bang - buncha info for yah.

  • GSS (vs) Cached DNS responses

    I am trying to understand the GSS product and how it provides 'immediate' redundancy across multiple data center(s).
    So lets assume that the GSS (with CNR installed) has been deployed and functions as the authoritative server for the domain (www.test.com). The goal is to provide active/standby type configuration between two data centers.
    If a client tries to access the page (www.test.com), the GSS replies with the address of server (e.g: 1.1.1.1) residing in Data Center(a). However lets assume after the response from GSS is sent to client and the client is trying to connect to the www.test.com using Ip address 1.1.1.1, Data Center(a) becomes unavailable. How will this connection get redirected to Data Center(b)'s IP address 2.2.2.2?
    All subsequest request from the client will be done using 'DNS cache' so the GSS does not come into the picture since the client already knows the IP address of www.test.com (1.1.1.1).
    Is this how it works or am I missing something here?
    Thanks in advance for the response.

    Syed
    There are few things you should keep in mind.
    User Workstation is not the real client for GSS. Its primarily the Client's DNS Server.
    With respect to caching you are very correct that GSS (for that matter any DNS based GSLB method) is prone to DNS caching issues.
    There are various points in the network that stores/caches DNS information.
    1. Client's DNS Servers
    2. Client PC's OS
    3. Browser on Client's PC
    To mitigate Client DNS Server issue you need configure the A record served by GSS with a smaller TTL value. This "A-record TTL value" dictates how long can DNS server caches a DNS record. So for example if you set A-record TTL value to 5 minute then the worst outage of service you will get will be 5 minutes (as Client's DNS server will only cache it for 5 minutes and at 6th minute Client's DNS server will contact GSS again and will get the active vip as answer.
    If you are using newer IE versions (6.x+) then you are in a better situation as these IEs try to resolve again if the web access to IP in DNS cache fails and hence will get the active IP on GSS.With Pre-6.x versions problem is severe as not only this feature is missing but also the DNS caching time is from 30 mins to 24 hours.
    With Firefox (last time I checked) this dns cache timeout is 15 minute (so in worst case scenario the service outage will be 15 minutes).
    Using google you can get lots of tools to disable dns caching on browsers. I know this is not a cool solution but it can be done.
    In nutshell yes GSLB has issues with DNS caching but it still gives you a solution which can move client to a different Data center (after dns cache timeout).
    Syed Iftekhar Ahmed

  • Caching JSP Response

    Hi,
    I am trying to get the response from the result of performing a pageContext.include("myPage.jsp") so that I can store it in cache to use the next time the page is loaded (for performance reasons). Does anyone know how to do this?
    Much Thanks!!

    Specifically, I want to get the String or byte array containing the page that will get sent back to the browser.

  • Disabling cached query responses?

    Here's the problem I have...
    Whenever I go to our SharePoint site to upload a document, CSA will flag whatever file I click on in the "Open file" window (before I go to upload) and query me if I want to give access to iexplore.exe to read the file. If a normal user is in this situation, they'd probably click no. Then, when you go to upload that file, the access is automatically blocked by the remembered query answer.
    The query I've made (I made a specific one for this) DISABLES the "Don't Ask Me Again" option. My question is how can I disable all cached responses so that users can deny access in a certain situation, then grant access in another? Or is there a way to force the Agent to clear it's cached responses every couple minutes?

    It is the Don't ask again checkbox available from the Query Settings page in the MC that controls whether the end user has the ability to have a query response remembered permanently. As the administrator, you decide whether or not users have the option to choose Don't ask again. If user queries do not include a Don't ask again option and responses are only cached temporarily (for approximately an hour) users can click the Clear button in the agent Query User Responses window to delete all temporarily cached responses.
    Look at the URL for more information
    http://www.cisco.com/en/US/products/sw/secursw/ps5057/products_configuration_guide_chapter09186a0080424780.html#wp962337

  • How to handle JSON response in XSL-Fo templates during PDF creation of the page

    XSL-FO in CQ5 converts xml output to PDF so for each new XML tag I need to introduce xsl-templates.
    But For ext-js javascript widget on the page that’s not part of CRX Node/page that shows result by making Ajax call and render JSON output. How to address that inside PDF page creation.
    Please share your thought.
    Thanks Chandra

    Declaratevly You can't do this.
    I use two event handler for state remembering:
    public static EventResult goToPage(BajaContext context,
    Page page,
    PageEvent pageEvent) {
    Page newPage = new Page(page.getProperty("nextPageName"));
    page.setProperty(NEXT_PAGE_NAME, null);
    newPage.setPropertyAsPage("returnPage", page, context.getPageEncoder());
    return new EventResult(newPage);
    public EventResult returnToPage(BajaContext context,
    Page page,
    PageEvent pageEvent) {
    Page oldPage = page.getPropertyAsPage("returnPage", context.getPageDecoder());
    return new EventResult(oldPage);
    StartPage.uix
    <handlers>
    <event name="nextPage">
    <bc4j:chaining>
    <bc4j:setPageProperty name="nextPageName" value="NextPage"/>
    <method class="..." method="goToPage"/>
    </bc4j:chaining>
    </event>
    </handlers>
    NextPage.uix
    <handlers>
    <event name="nextPage">
    <bc4j:chaining>
    <method class="..." method="returnToPage"/>
    </bc4j:chaining>
    </event>
    </handlers>
    method setPropertyAsPage save all page properties and state informations for page.
    On every page I use ctrl:page or ctrl:pageState DataObjectLists.
    On pages with search criteria I use ctrl:httpSession DataObjectList to save all criteria in one session. You must write event handler when you make search or trigger FIND event. In this event handler you must put every search form parameter in session.
    That's all from me! I hope this help You to resolve problems!

  • Empty JSON response can't be serialized

    Hi,
    FB4 B2
    I was getting an error from JSONSerializer object when the returned array has no elements inside. the returned JSON encoded raw data is a simple array representation: []. Is there anything I'm doing wrong, server side is php and I'm using PHP's json_encoder function. When I have elements inside the serializer works well.
    r. Sandor
    Error:
    Error: Error while Parsing
    at com.adobe.serializers.json::JSONDecoder/parseValue()[C:\perforceGAURAVP01\depot\flex\ide_ builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\json\JSONDecoder .as:249]
    at com.adobe.serializers.json::JSONDecoder/parseArray()[C:\perforceGAURAVP01\depot\flex\ide_ builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\json\JSONDecoder .as:431]
    at com.adobe.serializers.json::JSONDecoder/parseValue()[C:\perforceGAURAVP01\depot\flex\ide_ builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\json\JSONDecoder .as:221]
    at com.adobe.serializers.json::JSONDecoder/decode()[C:\perforceGAURAVP01\depot\flex\ide_buil der\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serializers\json\JSONDecoder.as: 178]
    at com.adobe.serializers.json::JSONSerializationFilter/deserializeResult()[C:\perforceGAURAV P01\depot\flex\ide_builder\com.adobe.flexbuilder.dcrad\serializers\src\com\adobe\serialize rs\json\JSONSerializationFilter.as:102]
    at mx.rpc.http::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::processResult()[E:\dev\gumbo_beta2\frameworks\ projects\rpc\src\mx\rpc\http\AbstractOperation.as:929]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\gumbo_beta2\frameworks\ projects\rpc\src\mx\rpc\AbstractInvoker.as:313]
    at mx.rpc::Responder/result()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\Responde r.as:56]
    at mx.rpc::AsyncRequest/acknowledge()[E:\dev\gumbo_beta2\frameworks\projects\rpc\src\mx\rpc\ AsyncRequest.as:84]
    at DirectHTTPMessageResponder/completeHandler()[E:\dev\gumbo_beta2\frameworks\projects\rpc\s rc\mx\messaging\channels\DirectHTTPChannel.as:446]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    Another possible workaround is use a drop-in replacement to the built-in JSONSerializationFilter:
    https://github.com/audreyt/plurk/blob/master/src/com/serialization/json/JSONSerializationF ilter.as
    https://github.com/audreyt/plurk/blob/master/src/com/serialization/json/JSON.as
    All it takes is changing the "import com.adobe.serializers.json.JSONSerializtionFilter" lines in service
    class's templates into "import com.serialization.json.JSONSerializationFilter", and empty arrays would start working.
    Theoretically one can also do this, though I have not tested it yet:
        SerializationFilter.registerFilterForResultFormat( 'json', new JSONSerializationFilter ());

  • JSON response

    Hi There,
    Is it advisible to use JSON with heavy traffic ..
    Thanks

    Depends. Hard to say based on the as far given information.

Maybe you are looking for