Dogstudio / highway

Highway - A Modern Javascript Transitions Manager
https://highway.js.org/
MIT License
1.43k stars 92 forks source link

Cache? Problem with attributes #25

Closed wezzou1 closed 6 years ago

wezzou1 commented 6 years ago

Hi, I'm wondering if this is a caching problem?, I'm trying to change the URL on click, with right attributes, it's working without highway, because the page is hard refresh on each click, So I'm wondering if you guys know how to fix this problem?

Here is a video that describe the problem! https://drive.google.com/file/d/1YGK8iNx59ep1hzpV_18CO7S5oOEBXbBX/view?usp=sharing

Anthodpnt commented 6 years ago

Hi @wezzou1,

I'm not sure to understand, Highway seems to change the URL properly, first time you have Malad then Slipad since you change the outfit model. What's the problem ?

Thanks, Anthodpnt

Anthodpnt commented 6 years ago

With the fix we pushed yesterday the entry in the cache has the full URL including parameters as key and the page HTML as value. So apparently you should get 2 entries in the cache, one for Malad and one for Slipad. Maybe you could debug it by logging Highway.Core.cache on NAVIGATE_END event like this:

// Call of Highway.Core
const H = [...]

// Events
H.on('NAVIGATE_END', () => {
  // Debug
  console.log(H.cache);
});

This way you'll be able to see what is put in the cache and give us a more detailed description of the problem if it concerns the caching of Highway :).

Thanks, Anthodpnt

wezzou1 commented 6 years ago

@Anthodpnt The problem here is that if I change the "permalink" from Målad to Slipad the selector will not select my option, As you can see when I'm click in to the product the last time, I'm clicking at Slipad and the URL change, but when I'm coming in to the product page it's Målad? when my select was Slipad, The first time works fine, but the next time dosen't

wezzou1 commented 6 years ago

skarmavbild 2018-09-21 kl 11 41 12

wezzou1 commented 6 years ago

@Anthodpnt

First console.log => Going from product-list in to the product Sec console.log => Going from product, back to product-list Third console.log => Change permalink on product Fourth console.log => Going to the new permalink.

Anthodpnt commented 6 years ago

@wezzou1 I think you don't have the v2.0.4 of Highway with the fix we pushed yesterday because the keys of the cache are the pathname of the URLs and we changed it yesterday.

wezzou1 commented 6 years ago

@Anthodpnt Hmm, I tried @dogstudio/highway": "^2.0.4" and seems not to work....

Anthodpnt commented 6 years ago

@wezzou1 Did you remove the node_modules folder and the lockfile before reinstalling your modules ?

wezzou1 commented 6 years ago

@Anthodpnt yes, I did!

Anthodpnt commented 6 years ago

Can you open the source code of Highway you're using in the node_modules and look for this.cache.set and send be the line you find please ?

wezzou1 commented 6 years ago

@Anthodpnt this.cache.set(this.location.url, this.properties);

wezzou1 commented 6 years ago

@Anthodpnt and sec line this.cache.set(this.location.pathname, this.properties);

Anthodpnt commented 6 years ago

@wezzou1 Can you try v2.0.5 please ? It should completely fix the problem.

wezzou1 commented 6 years ago

@Anthodpnt will try now!

wezzou1 commented 6 years ago

@Anthodpnt hehe... now it's the same issue as it was yesterday with search, if I'm clicking on an another link the transition runs and URL changes, but I'm still at same page...

wezzou1 commented 6 years ago

@Anthodpnt I've got Map(1) {undefined => {…}} on every single page

Anthodpnt commented 6 years ago

@wezzou1 That's really weird, I'll need time more time to fix this one then. I'll let you know when it's done cause I don't have time right now to run deeper tests.

Anthodpnt commented 6 years ago

@wezzou1 Nevermind, can you try v2.0.6, I was referring location.url but it should have been location.href...

wezzou1 commented 6 years ago

@Anthodpnt will do! :)

wezzou1 commented 6 years ago

Wooop wooop! 👍 It's now working perfect! Thanks again @Anthodpnt!

Anthodpnt commented 6 years ago

Awesome !!! 🎉 Really sorry for the back and forth ! Again, thank you for playing with it and sending this kind of useful issues to us.