title: Stop multiple AJAX requests in same page
body: <p>I made a web page, on load of which an AJAX request is fired which brings in data and then updates that page.</p>
  
  <p>Now everything is working fine except the ajax request is fired every time page is loaded even though the content on the server is not changed. So how can I optimize this process so that page doesn't fire ajax request again and again ?</p>
  
  <p>the code process works as follows</p>
  
  <p>I check for the url using regex
  courseInfoRegexUrl = /(http|ftp|https)://[\w]+/[\w]+/courses/course(.php|)?/gi;</p>
  
  <p>if it matches then I call a function with an arg, the function is as follows :-</p>
  
  <pre><code>function getCourseData(name){
      $.ajax({
          url : "api/getCourseData.php",
          type : "POST",
          data : {name:name, token:catoken},
          success : function(d){
              d = JSON.parse(d);
              console.log(d);
              getCourseReviews(name);
  
          },
          error : function(error){
              generalErrorShow("Some error ocurred. Try refreshing the page");
          }
      });
  }
  </code></pre>
  
  <p>its call example is getCourseData("comp1");</p>
  
  <p>Thanks</p>