Skip to content

Jquery JSONP requests are not getting cached by CloudFront #183

@jmalczyk

Description

@jmalczyk

A JSON-P request issued by jQuery assigns a callback=somerandomnumber parameter, so as not to conflict with other calls that could potentially be happening at the same time. Unfortunately this means a sql result is never cached. Fortunately the same problem does not exist for tiles, image sources can be assigned cross-domain.

The solution is to explicitly set a callback function name instead of letting jquery assign one when making sql api requests. Make sure to pick something unique to the sql request, like ac{term} for an autocomplete request for {term}.

$.getJSON(
   "http://blahblahblah.cloudfront.com/api/v2/sql?" +
      "q=select n, v from ac where n~*'\\mPum' or v~*'\\mPum'&callback=acPum",
   function(response) {
       self.handleAutocomplete(response);
   }
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions