php - angular way of getting data -


i have site driven ajax. when user goes category page want show products there. what's best way fetch products category? have 2 options:

  1. save products js variable threw php @ first load of website, when user goes category filter array products has category , send them view

  2. dont save produts variable in beggining, fetch them threw api when user touch category

i think first option better because products loaded in begginging , if user touch 50 categories, not have send 50 requests products. i'm not sure(maybe potencial problem if have big amount of products)

thanks.

you load of product data after angular app has loaded.

at rate, vastly depends on how product data have , current load time. it's small amount of products combined make 100kb json object, doesn't matter.

but if have more trivial amount of data, and/or average user accessing small percentage of product data, makes more sense load on demand. can keep data in memory if user switches , forth cat -> cat b -> cat a, load each cat & b once.

in end, need analyze load times , how data thinking of loading. if loading in 1 go still acceptably fast should fine, it feels slow need optimize , load more things on demand needed.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -