URL query parameters
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.
Query parameter | Response |
---|---|
_format=json | HTTP status code in JSON format. |
_format=js | JavaScript function that dynamically creates an (function(window, undefined) { d=window.document; f=d.createElement('IFRAME); f.src='http://example.com/recipe'; }) |
_format=_frame | HTML document with an <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:
|
_format=jsonp &_callback=functionName | JavaScript function whose argument is the HTTP status code in JSON format. For example, if the function name is myfunc({ "status":"ok", "result":[] }); |
_format=jsonp &_callback=functionName &_result=html | JavaScript function whose argument is a JSON representation of the response with two keys:
For example, if the function name is myfunc({" status":"ok", "result":"<html><body><p>hello</p></body></html>}); |
_format=oembed | JSON representation of the requested page that can be embedded in a third-party site. For additional information about this format, see oEmbed. |
_renderer=json | JSON 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=styleguide | JSON 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