I have an ecommerce system and a blog both working independently on two servers. The ecommerce server reverse proxies the blog
/blog
This is all working fine, however my question is what is the best way to attain the header webpage element from one server to the other, taking into consideration there are dynamic elements within the header, basket count and user name if logged in.
The only solution I came up with is to grab the header via curl or the likes and cache periodically. Then enhance it with session data which is shared across the servers, i.e. the basket count, username.
Thanks in advance, hope this makes sense
Andrew
Since you’re using a single server to reverse proxy, you can perform ajax requests to this single site without worrying about any of the cross-site policy shenanigans.
Lets say you have the following
From a page served from under
/blogyou can fetch a url like/notblog/basket.phpwith an ajax request, and update various parts of your header with the relevant information.Alternatively (a far more crude solution) would be to include
/notblog/basket.phpas a script file, and dynamically generate javascript that simply prints your header contents. (remember to add headers to prevent it from caching!)Both of these require an extra request to your site, but so would your proposed solution of using cURL.