HTML 代码的缓存部分 - ASP.Net
我遇到的情况是,我有一个带有选项卡的页面,可以容纳用于各种功能的多个按钮。每个选项卡都有不同的功能集(例如客户、订单和管理)。
它最初的设计方式是我加载所有选项卡及其所有按钮。显示的按钮取决于登录者。
此外,如果用户单击某个功能,它会加载该页面的代码,替换该选项卡中的按钮以及其他选项卡的所有代码。我认为这不是很有效,我猜想使用 AJAX 加载选项卡的内容会更好。
完成此行为并使代码响应更快的最佳方法是什么?我的想法是,我会将选项卡 div 内部的 html 存储在会话变量中,因此我只需要在用户登录时获取一次代码,然后根据当前选择的内容将其返回给用户选项卡。
I have a situation where I have a page with tabs to hold multiple buttons for various functions. Each tab is for a different set of functionality (e.g. customers, orders and admin).
The way it was originally designed was I load all of the tabs and all of their buttons. The buttons shown is dependant on who is logged on.
Additionally, if a user clicks on a function it loads the code for that page, replacing the buttons in that tab as well as all of the code for the other tabs. I don't think this is very efficient and I would guess it would be better to load the content for the tabs using AJAX.
What would be the best way to accomplish this behaviour and make the code more responsive? My thought is that I would store the html that goes inside of the tab divs in the session variables, so I would only need to get the code once when the user logs on and then just serve it back to the user based on the currently selected tab.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要保存会话,您的矿井中必须具有:
会话数据全部保存在一起,并在每个页面加载的开始读取时一起读取,并在每个页面读取结束时一起写入。并且会话会锁定所有用户,因此如果您添加太多数据并在会话上造成读写延迟,这可能会影响您网站上的用户。想象一下创建一个大的html页面数据,你保存在session上,大约有300k,然后你做同样的10次,那么session数据将是3M,必须一直读写。
因此,它就像在用户会话之后添加额外的数据。
如果可以在数据库上进行自定义缓存,并仅使用会话密钥 ID 保存它,并且仅在用户进入该页面时加载它们,仅在用户更改它时保存它,那就更好了。
另一方面,如果您没有很多用户,并且需要使其快速,或者您没有数据库连接,或者很难制作小型自定义缓存,那么将会话用于其中的一两个数据。
To save on session you must have on your mine that:
The session data are saved all together, and read all together on the start reading of every page load, and write all together on the end of every page read. And the session lock all users, so if you add too much data and create a delay to read and write on the session, this can possible affect the users on your site. Imaging to create a big html page data that you save on session and its about 300k, and then you make the same 10 times, then the session data will be 3M that must reads and writes all the time.
So its like to add an extra data that follow the user session.
Its better if its possible to make your custom cache on a database, and save this just using the session key id, and load them only when the user enters that page, save it only when user change it.
From the other hand if you do not have many users, and you need to make it quick, or you do not have database connection, or is difficult to make a small custom cache, then use the session for one or two data of that.