Jump to content

Enabling Cache Causes JS Errors


Recommended Posts

Hello all,

 

The error is occurring on the product page so let me explain what the default behavior of the page is before proceeding.

You can find an example here https://sportstown.me/shoes/7400-nike-capri-3-leather-gs.html

 

I tweaked the original code a bit to include a Google Map down at the bottom. The purpose of this map is to eventually show the users where the product combination they selected is available in the country. That's pretty much it.

 

I only recently enabled caching for my e-commerce website via the back-end (Advanced Parameters -> Performance) but then I noticed an unwanted behavior on the product page. The moment I enable caching and visit the link I posted earlier, nothing wrong happens, however if I refresh the page I notice that I get a JS error telling me a certain function is undefined. That function that I created is however defined in a file called "stores.js" located under "themes/my_theme/js/stores.js" yet for some reason the caching omits this file all-together.

 

Can anyone pinpoint what the problem is or might be? As a short-term solution I disabled caching via the back-end but I don't want to keep it that way for the sake of optimizing my website's performance. I am using Prestashop 1.6.0.9.

 

Thanks in advance.

Link to comment
Share on other sites

  • 3 weeks later...

Hello Nemo1,

 

So sorry for the late reply, but I was pre-occupied with other stuff. I took your advice and I went to "Advanced Parameters" -> "Performance" and disabled "Smart cache for JavaScript", and that seemed to do the trick, therefore it is definitely the case of bad commenting like you said.

 

I will mark your answer as solved. Thanks for the help!  :) 

Edited by AhmadHamdan (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...