在Azure Webrole中动态更新sitemap.xml [英] Dynamically update sitemap.xml in Azure webrole

查看:109
本文介绍了在Azure Webrole中动态更新sitemap.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将现有网站迁移到Azure.在蔚蓝的韦伯里,我有
1.网站位于默认端口和
2.另一个端口的服务说:8000

I am moving my existing website to Azure. In azure webrole I have
1. Website at default port and
2. Service at another port lets say :8000

现在,我的网站创建了一些动态页面,并且要求使用新的URL更新sitemap.xml.在开发阶段,我可以通过服务创建和更新sitemap.xml文件.但这在登台服务器上是不可能的.

Now my website creates some dynamic pages and the requirement is to update the sitemap.xml with the new URLs. At development stage I am able to create and update the sitemap.xml file from service. But this is not possible on staging server.

我无法理解为什么会发生.任何人都可以告诉我一种解决方案,在该解决方案中可以从服务"在网站的根文件夹中创建sitemap.xml文件吗?

I am unable to understand why is it happening.Can any one tell me about a solution where I can create a sitemap.xml file at the root folder of website from the Service?

推荐答案

我会说您的问题比sitemap.xml本身大得多!

I would say you have far bigger issue than the sitemap.xml itself!

在Azure WebRole中工作,您具有非持久存储.这就是我们所有人为云的可伸缩性/弹性/弹性所付出的代价.这意味着,如果您的代码运行的硬件(裸机)发生故障,Azure将在新的金属件上实例化一个新的硬件,并将部署您的原始程序包.到那时,所有动态生成的页面都将丢失,因为它们不是原始包的一部分.

Working in an Azure WebRole you have an non-persistent storage. This is the price we all pay for the scalability/elasticity/resilience of the cloud. This means that if something happens to the hardware (bare metal) where your code runs, Azure will instantiate a new one on a new piece of metal and will deploy your original package. At that point all your dynamically generated pages are lost, because are not part of your original package.

对于您的网站从用户上传/生成的内容/接受的所有内容/等等,您必须使用

For all the content your site generates/accepts from user uploads/etc you have to use Azure Blob storage to persist. Once you got your dynamic content in a blob storage you have couple of options to deliver it to end user:

  • ASP.NET Handler (ashx) which will read the blob content and re-stream(send) it back to the end user (I would not go for this);
  • Dynamically generate appropriate links to the content in the blob storage. Using Shared Access Signature if content is has to be protected and not available to everyone;
  • Using custom VirtualPath provider to make remote content (Azure Blob) looks like local for the end user.

现在您可能已经猜到了-使Sitemap.xml始终保持最新的最佳方法是再次使用ASP.NET Handler来动态生成其内容.当然,使用某种类型的缓存(甚至可能是blob)可以避免在每次对Sitemap.xml发出请求时进行昂贵的调用和对象图.

And now you probably already guessed - the best way to have Sitemap.xml always up-to-date is use again ASP.NET Handler to dynamically generate its content. Of course using caching of some sort (may even be blob) to avoid expensive calls and object graphs upon each request to Sitemap.xml.

这篇关于在Azure Webrole中动态更新sitemap.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆