Topics

URL query parameters


In This Guide

Dari provides URL query parameters to facilitate debugging. A query parameter is appended to a URL with a question mark (?) if it’s the first parameter in the query string, or an ampersand (&) if it is not the first parameter in the query string.

There are Dari query parameters to invoke the Contextual Debugger and Reloader. In addition, the following query parameters are available.


Cache

http://{yoursite.com}/{page}/?_cache=false

Dari automatically provides SQL query caching when returning objects. When the same content is requested in separate SQL queries, caching limits the number of queries to one, thereby consolidating queries.

To turn caching off, add ?_cache=false to the page request.

To see the difference between caching and not caching, use the Contextual Debugger, first with caching on (?_debug=true&_cache=true), and then with caching off (?_debug=true&_cache=false). Scroll down to the Dari Profile table, and examine the count for SQL with and without caching.


Modifying the response format

When serving a page, Brightspot normally assembles the response in HTML format using the view system. You can specify a different format, a technique that is helpful when debugging or embedding the response in a different page.

You specify the output format using a query parameter _format or _renderer as described in the following table.

Examples of using the query parameters include the following:

Query parameterResponse
_format=jsonHTTP status code in JSON format.
_format=jsJavaScript function that dynamically creates an iframe pointing to the requested page’s permalink.
(function(window, undefined) {
  d=window.document;
  f=d.createElement('IFRAME);
  f.src='http://example.com/recipe';
})
_format=_frameHTML document with an <iframe> pointing to the requested page’s permalink.
<html>
    <body>
        <iframe src="http://www.example.com/fast-food-found-on-exoplanet" 
></iframe>
    </body>
</html>
_format=json &_result=html

JSON representation of the response with two keys:

  • status: HTTP status code
  • result: Requested page as an escaped HTML string
_format=jsonp &_callback=functionName
JavaScript function whose argument is a JSON representation of the response with two keys:

  • status: HTTP status code
  • result: Requested page as an escaped HTML string

For example, if the function name is myfunc, the response is similar to the following:

myfunc({"
  status":"ok",
  "result":"<html><body><p>hello</p></body></html>});

_format=jsonp &_callback=functionName &_result=html

JavaScript function whose argument is a JSON representation of the response with two keys:

  • status: HTTP status code
  • result: Requested page as an escaped HTML string

For example, if the function name is myfunc, the response is similar to the following:

myfunc({"
  status":"ok",
  "result":"<html><body><p>hello</p></body></html>});

_format=oembedJSON representation of the requested page that can be embedded in a third-party site. For additional information about this format, see oEmbed.
_renderer=jsonJSON representation of the requested page as it is stored in the database, similar to the following:
{
  "class" : "content.article.ArticleViewModel",
  "body" : "A survey of 5 million cat owners proved that cats are indeed better pets than dogs.",
  "headline" : "Cats Are Better Than Dogs"
}
_renderer=styleguideJSON representation of the requested page used to populate a template.

Examples of using the query parameters include the following:

  • http://<hostname>/cats-are-better-than-dogs?_renderer=json
  • http://<hostname>/cats-are-better-than-dogs?_renderer=styleguide
  • http://<hostname>/cats-are-better-than-dogs?_format=_frame