iOS experiencing delays when calling Parse.Cloud.run

I'm currently working on a code snippet that involves running a parse cloud function followed by processing the results. This code utilizes their javascript api (1.3.0) and is implemented in an ionic framework app. Interestingly, when executed on a Mac using Chrome browser, the response time is consistently around 500ms. However, when the same code is run on iOS devices, the performance varies significantly. It can take anywhere from 3 to 20 seconds to complete. Both the Mac and the iOS devices are connected to the same wireless network. I'm puzzled as to why there's such a discrepancy in speed between the two platforms and what steps I can take to optimize it.

var start = Date.now();
console.log("PARSE CLOUD RUN");            
Parse.Cloud.run('getFixtures', {teamID : teamID, divisionID : divisionIDs}, {
    success: function(response) {
        console.log("PARSE CLOUD SUCCESS :" + (Date.now() - start));

Answer №1

There is an effective solution to managing this scenario more efficiently. Utilizing Parse query's built-in caching functionality can simplify the process of storing query results on disk. In the event of no network connectivity, your application can retrieve the cached result. Caching also enhances app performance by eliminating the need to fetch data from Parse every time the app is launched.

By default, caching is turned off. However, it can be easily activated with just a single line of code. Insert the following code within the queryForTable: method (after PFQuery initialization):

query.cachePolicy = kPFCachePolicyCacheThenNetwork

Parse query provides support for various cache policies. The kPFCachePolicyCacheThenNetwork policy is only one option available. This policy first retrieves data from the cache before accessing the network.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it beneficial to create a separate component for React form elements?

I've come across advice that suggests when unsure, turning an element into a component is a good idea. But what are the actual benefits of converting form elements like <input /> into components? Let's consider the following example: cons ...

Interrogating a MongoDB using the Mongo ID within a node.js application

Currently, I am working with node.js and mongodb and attempting to query the database based on the mongo generated ID using the code snippet below: collection.findOne( {_id:doc._id} , function(err, item) {}); Although I am confident that my doc._id is an ...

The identifier 'name' is not found in the specified data type

How can I resolve the error 'Property 'name' does not exist on type' in TypeScript? Here is the code block : **Environment.prod.ts** export const environment = { production: true, name:"(Production)", apiUrl: 'https://tes ...

Retrieve the constant for the constraint based on the size of the class

I'm currently working on retrieving the constraint constant of a size class programmatically. Here is the width constraint: https://i.sstatic.net/o74KZ.png To access the constraint constant, I've created an outlet for the control and retrieve ...

Update the PHP webpage dynamically by utilizing AJAX and displaying the PHP variable

I am working on a PHP page that includes multiple queries, and I would like to be able to include this page in my index.php file and display the results with an automatic refresh similar to the Stack Overflow inbox feature. Is there a way to achieve this ...

Activate a switch in a single table after its information has been transferred to a different table

I have a dilemma involving two tables - one displaying a list of items and the other serving as an empty favorites table. Users can select items from the first table and click 'Add' to move them to the favorites table. Once added, the 'Add& ...

Exploring the world of AngularJS and delving into the

Lately, I've come across articles discussing Google's ability to now crawl websites and render CSS and Javascript. For example, Google themselves have talked about it in this article: My setup involves a single page application built with Angula ...

Leveraging Node.js to establish a connection between two pug files

Recently, I decided to delve into the world of pug and JavaScript. However, I seem to be facing a small issue that I can't quite figure out on my own. My project involves creating multiple .pug files with various text content that I can navigate betwe ...

Changing the status of a higher-level component from within a nested component using immutable methods

I have a collection of objects with various properties. columns = [ {Header: ƒ, Cell: ƒ, sortable: false, show: true}, {Header: ƒ, accessor: "firstName", sortable: false, show: true}, {Header: ƒ, accessor: "status", so ...

What is the best way to create a Div element that functions as a button, becoming active when clicked while deactivating all other Div elements

function toggleButton1() { $("#button1").toggleClass("button-active button-inactive"); $("#button2").toggleClass("button-inactive button-active"); $("#button3").toggleClass("button-inactive button-active"); } function toggleButton2() { $("#butto ...

Error: React unable to locate module './WebpackMissingModule'

Recently I started diving into React, and I'm encountering some difficulties trying to export components. Here is my current index.js file setup: import React from 'react'; import ReactDOM from 'react-dom'; import SearchBar from ...

Nodejs functions properly on a local machine, however, it encounters issues when deployed on a VPS

My nodejs/javascript code seems to be running fine on my local pc, but when I try to run it on my vps, it's not working properly. Even though I have the same node_modules installed and the code is identical. Here's a snippet of my code for refere ...

Utilizing Ajax with the navigation of back and forward buttons

As I embark on the journey of developing a new application, I am determined to embrace a full ajax style approach :) My weapon of choice for ajax requests is Jquery. The main JS file will receive variables from the link that was clicked and based on those ...

Issue with React application and nginx configuration causing components not to switch when using router functionality

I have encountered an issue while trying to deploy my React app using nginx. The problem I am facing is that when I change routes, for example to /about, the front end does not update and remains on the index page. Here is the configuration in sites-avai ...

Confusion about Redirecting Windows

Using a JavaScript function, I am trying to redirect the window to a different webpage using this command: window.location.replace("/EluLander/doctor/doctordash.html"); The URL of the webpage when opened manually is: file:///C:/Users/Elijah%20Spiegel/D ...

Block-level declarations are commonly used in TypeScript and Asp.net MVC 5

In my asp.net mvc5 project, I decided to incorporate TypeScript. I created an app.ts file and installed the nuget-package jquery.TypeScript.DefinitelyTyped. Here is a snippet of the app.ts code: /// <reference path="typings/jquery/jquery.d.ts"/> cl ...

Leveraging React Native's Async Storage to store and retrieve values consistently within the Render method

Is there a way to set and get a value in the render method with just one line of code, by using a variable between tags? I attempted this approach but encountered an error message stating "Can't find variable: storage_key". import React, { Component } ...

How come my attempts to make my jQuery fade in upon button click aren't working?

#rock { display: none; position: relative; left: 49.4% } #paper { display: none; position: relative; left: 49%; bottom: 81px; } #scissors { display: none; position: relative; left: 48.14%; bottom: 162px; } #shoot { display: none; ...

Is it impossible to destroy a Ckeditor instance?

How do I destroy a ckeditor instance? I am facing an issue with double instances of ckeditor. I need to destroy it. When I check the code in console.log(editorID), it shows the same values as in the images. After adding Chapter1, I see 2 instances: texta ...

Importing d3.JS JSON data without polluting the global scope

Here is a JSON object: { "temp_data": [10,15,20] } I'm trying to import it: var temp_data; //Importing from JSON if(true){ d3.json("graph.json", function(error, graph) { if (error){ throw error; } temp_da ...