LAMP网站上更长的目录路径/名称和URL的缺点是什么? [英] What are the downsides of longer directory paths/names and URL's on a LAMP site?

查看:274
本文介绍了LAMP网站上更长的目录路径/名称和URL的缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尽可能高效地组织我的网站上的图片,而且还有更长的目录路径/名称和URL在LAMP网站上的缺点是什么?我热衷于使用许多嵌套的目录,所以没有子目录有超过1,000个子目录。



在最坏的情况下,图像将被存储在如下所示:

  ./ images / 76/543/7654321/640 / 1.jpg 

有如此多的子目录有一些严重的缺点,比较简单:

  ./ i / a7 / c3 / 5e.jpg 

我想,服务器要挖掘的子目录越多,需要的时间越长,目录结构越长,网址越长,所以HREF将占用的空间越多在HTML文档中。但是会有多大的差异呢?假设我们扩展到数以百万计的用户,这是我需要考虑的一个问题(简短的结构与long dir structrue)?



对于上下文,请查看< a href =https://stackoverflow.com/questions/6877771/what-is-the-fastest-and-most-efficient-way-of-storing-and-fetching-images-when-yo>这个。



谢谢!

解决方案

拥有大量一个目录中的文件可以使其缓慢。你是对的,把它分开。但是,您可以尝试通过使用路径名中的所有字母数字字符来减小长度。



如果你有:

  / images / [a -z0-9] {3} / [a-z0-9] {3} / [a-z0-9] {3} .jpg 
/images/abc/def/ghi.jpg

使用以上您可以存储101559956668416图像。这似乎是可笑的,可能是这样的:

  / images / [a-z0-9] {2} / [a-z0 -9] {2} .jpg 
/images/ab/cd.jpg

With以上您可以存储1679616图像。这是一个合理的数字,但可能不足以满足您的需求。那么这样呢:

  / images / [a-z0-9] {2} / [a-z0-9] {2} / [a-z0-9] {2} .jpg 
/images/ab/cd/ef.jpg

这允许2176782336(20亿)图像,每个目录只能有最多1296个子文件/目录。



混合一些大写字母,甚至一些符号,你可以减少更多。
个人我会去最后一个选项。这似乎是一个很好的平衡。


What are the downsides of longer directory paths/names and URL's on a LAMP site?

I am trying to organize images on my sites as efficiently as possible, and I'm keen on using many nested directories so that no sub-directory has more than 1,000 sub-directories.

In a worst-case scenario, images would be stored looking something like this:

./images/76/543/7654321/640/1.jpg

Are there any serious downsides to having so many sub-directories vs. something simpler like this:

./i/a7/c3/5e.jpg

I suppose the more sub-directories the Server has to dig in to, the longer it's going to take, and the longer the directory structure is, the longer the URL will be, so the more space the HREF will take up in the HTML doc. But how much of a difference will that make? Let's say we scale up to millions of users, is this something I need to take into consideration (short dir structure vs long dir structrue)?

For context, please view this.

Thanks!

解决方案

Having a large number of files in one directory can make it slow. You are right to split it up. You can however try to reduce the length by using all alphanumeric characters in the path names.

If you were to have:

/images/[a-z0-9]{3}/[a-z0-9]{3}/[a-z0-9]{3}.jpg
/images/abc/def/ghi.jpg

With the above you can store 101559956668416 images. This seems ridiculous so perhaps something like:

/images/[a-z0-9]{2}/[a-z0-9]{2}.jpg
/images/ab/cd.jpg

With the above you can store 1679616 images. This is a reasonable number but might not be enough for your needs. So how about this:

/images/[a-z0-9]{2}/[a-z0-9]{2}/[a-z0-9]{2}.jpg
/images/ab/cd/ef.jpg

This allows for 2176782336 (2 billion) images and each directory will only ever have a maximum of 1296 child files/directories.

Mix in some capital letters and perhaps even some symbols and you can get away with even fewer. Personally I would go with the last option though. It seems to be a nice balance.

这篇关于LAMP网站上更长的目录路径/名称和URL的缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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