static-content interview questions
Top static-content frequently asked interview questions
Looking at different options:
One is to just put the static pages in the public/ folder, but I do want the header from layout/application to be consistent.
I tried this, but I got an error:
# in routes.rb:
map.connect '*path', :controller => 'content', :action => 'show'
# in content_controller.rb:
def show
render :action => params[:path].join('/')
end
All I want is an easy way to put together things like my faq, contact, tos, privacy, and other non-application type pages somewhere easy by just creating an .rhtml. who has done this?
Source: (StackOverflow)
I have a Spring Boot web application, and I would like to serve static content located in a shared Dropbox directory on my Linode VPS (~/Dropbox/images). I've read that Spring Boot will automatically serve static content from
"classpath:/META-INF/resources/",
"classpath:/resources/",
"classpath:/static/",
"classpath:/public/",
but of course my Dropbox directory is not on the classpath.
Although I could configure Apache to serve the images in my Dropbox folder, I would like to take advantage of Spring Security to restrict access of the static content to authenticated users.
Source: (StackOverflow)
I am using a custom ControllerFactory (to use Castle Windsor's IOC to create controllers), and I notice it's getting requests to create a controller for "favicon.ico". I have put a favicon.ico file in my Content folder, but I'm still getting these requests.
How do I resolve this and serve static content without trying to create controllers?
Source: (StackOverflow)
I got application server running in Windows – IIS6.0 with Zend Server to execute PHP. I am looking for lightweight static content only web server on this same machine which will relive IIS form handling static content and increase performance.
It need to be only static content web server – maximum small and maximum effective – lighttpd seems too big because allow to FastCGI
EDIT: Bounty is for: Windows, static content ONLY, fast, and lightweight
Windows Server 2003
Source: (StackOverflow)
This question already has an answer here:
I have a tag A in which when clicked on, it appends another tag B to perform an action B on click. So when I click on tag B, action B is performed. However, the .on
method does not seems to be working on the dynamically created tag B.
My html and jquery for tag A is as below:
<a id="address" class="add_address btn btn-inverse btn-medium pull-right push-top">Add Shipping address</a>
$('.add_address').click(function(){
//Add another <a>
$(document).append('<a id="address" class="pull-right update btn btn-inverse btn-medium push-top">Update</a>');
})
When tag B is clicked, some action B is performed. My jquery is as below:
$('.update').on('click',function(){
//action B
});
I have some non dynamic content which has class ".update" as well. In the .on()
method above works fine for the non dynamic content, but not for the dynamic content.
How can I make it work for dynamic content?
Source: (StackOverflow)
I have a Java web application, using Spring and Struts, running on Tomcat 5.5. I want to load static images that will be shown both on the Web UI and in PDF files generated by the application. Also new images will be added and saved by uploading via the Web UI.
It's not a problem to do this by having the static data stored within the the web container but storing and loading them from outside the web container is giving me headache.
I'd prefer not to use a separate web server like Apache for serving the static data at this point. I also don't like the idea of storing the images in binary in a database.
I've seen some suggestions like having the image directory being a symbolic link pointing to a directory outside the web container, but will this approach work both on Windows and *nix environments?
Some suggest writing a filter or a servlet for handling the image serving but those suggestions have been very vague and high-level without pointers to more detailed information on how to accomplish this.
Source: (StackOverflow)
I have an Azure Website/Web App that is incredibly slow to serve static JS and CSS files but seems perfectly fine serving binary.
To test the problem I uploaded two 30MB files, one big.js and the other big.rar. The JS file downloads at around 100KB/s if I'm lucky. The RAR file downloads at around 4,000KB/s. The results are extremely consistent.
I've checked in Fiddler and gzip compression is occurring in both cases. As expected, the JS file is being sent with the MIME type application/x-javascript whereas the RAR file is being served as application/octet-stream.
I am struggling to understand this - why would IIS serve one type of static content so much slower than another?
Source: (StackOverflow)
I am using forms authentication in IIS7 to password-protect a dev site, but the authentication seems to get by-passed when the site contains only static HTML files + login.aspx + web.config.
When I renamed the files to .aspx, I am prompted with the login form
I am not doing anything fancy. I have a very simple login script and it should just redirect to index.html afterward.
Any suggestions? To summarize, the entire site is using HTML (for now) and needs to be password protected.
<authentication mode="Forms">
<forms name="appNameAuth" path="/" loginUrl="~/login.aspx" defaultUrl="index.html" protection="All" timeout="525600">
<credentials passwordFormat="Clear">
<user name="[user]" password="[password]" />
</credentials>
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
Source: (StackOverflow)
It seems that in order to force users to refresh cached static files (e.g., .css, .js) some sites (e.g., stackoverflow.com) append querystrings to the end of files. For example:
<link rel="stylesheet" type="text/css" rel='nofollow' href="http://sstatic.net/stackoverflow/all.css?v=9ea1a272f146">
I think this is a good idea, and am inclined to start doing this as well. However, I have heard that there are downsides, such as proxies not properly caching files if a querystring is present.
What are the downsides to this type of versioning?
Source: (StackOverflow)
I'm using AppFog PaaS system for a few days, and I love it, It's probably the best PaaS system that I've tested (I've used other 3 ones previously), but didn't find information about how to serve static content with the Web server in frontend (Apache https or nginx) I'm not sure what server is being used.
My app is a Python WSGI with CherryPy and works perfectly in AppFog but I don't wan't CherryPy to serve static content, I think that Apache httpd or nginx is a better option for that.
Source: (StackOverflow)
We're about to deploy our .NET web application to an Azure Web Role. I'm just wondering how others have handled their static content, specifically images and css? At the moment our application package is about 25mb but 18mb of that is derived purely from images, things like navigation buttons, icons and template components that rarely ever get updated. Would it be wise to partition this out of the deployment package and move it to blob storage?
I have a few doubts about this approach that I'm wondering are valid...
80% of our site runs in a HTTPS environment. Will accessing images in a blob store introduce cross-scripting problems?
Vulnerability to money leakages, if someone tries to maliciously hammer our images (most are under 20kb)?
I'm struggling to see how it's possible to upload files to a blob container (from VS2010 + Azure SDK) with directory naming convention so I don't need to rewrite 1000s of path references? I appreciate directories are an abstract concept in blob containers, but I can write files with a forward slash to imitate this in code. Obviously Windows does not allow me to do this before I upload in Visual Studio.
Any thoughts or alternative strategies would be welcome. The goal really is to shrink our deployment package to speed up the deploy time. Also I quite like the idea of offloading the image serving to a dedicated node to improve the performance on the web server, maybe my image collection is so small that it's hardly worth bothering?
Update 16th May ------------------------------------------------------------------------
Here's what I did in the end:
1.Transferred all images + css to blob storage containers. I maintained the structure of any sub-directories within the images and css folders.
2.Applied a URL Rewrite rule in our web.config file as follows..
<rewrite>
<rules>
<rule name="imagestoazure">
<match url="images/(.*)" />
<action type="Redirect" url="https://xxxxx.vo.msecnd.net/images/{R:1}" />
</rule>
</rules>
</rewrite>
3.Excluded the images + css folders from the application and deployed.
My deployment is now much smaller and the images are running off a CDN freeing up bandwidth, improving downloads speeds and releasing some load off the web-server.
Update: September 2015
When reviewing this recently I came across the following guide from Microsoft. It goes into more detail about how you can automate the deployment of your assets and cache bust using querystrings.
Serve Content from Azure CDN in Your Web Application
Source: (StackOverflow)
I want to create a virtual host in apache such that it serves only static content like stylesheets, videos, images, javascripts, text files, etc. I am not looking at any "processing" capabilities from this virtual host.
Source: (StackOverflow)
I am in need of a scalable and performant HTTP application/server that will be used for static file serving/uploading. So I only need support for GET
and PUT
operations.
However, there are a few extra features that I need:
- Custom authentication: I need to
check credentials against a database for each request.
Thus I must be able to integrate propietary
database interaction.
- Support for
signed access keys: The access to
resources via
PUT
should be signed
using a key like http://uri/?key=foo The key then contains information about the request like md5(user + path + secret) which allows me to block unwanted requests. The application/server should allow me to check for this.
- Performance: I'd like to avoid piping content as much as possible. Otherwise the whole application could be implemented in Perl/etc. in a few lines as CGI.
Perlbal (in webserver mode) looks nice, however the single-threaded model does not fit with my database lookup and it does also not support query strings.
Lighttp/Nginx/… have some modules for these tasks, however it is not feasible putting everything together without ending up writing own extensions/modules.
So how would you solve this? Are there other leightweight webservers available for this?
Should I implement an application inside of a webserver (i.e. CGI). How can I avoid/speed up piping content between the webserver and my application.
Thanks in advance!
Source: (StackOverflow)
I have a rails application with static content in the public
directory (e.g. public/index.html
) and additional static content in nested subdirectories (e.g. public/one/two/index.html
).
All the static content is served correctly if I run it locally via script/server
but when I upload it to Heroku the top-level page loads correctly but the nested content returns a 404.
I've found a number of resources (for example this question) which discuss static content in rails but they all seem to assume a fairly simple structure with a single directory containing all the files.
Is there any way I can fix this?
Source: (StackOverflow)
I cloned a client's Orchard CMS. The repository that I cloned did not contain the Media
folder (this is good). So, a next step was to restore the Media/Default
directory from a .zip
backup. Now that I've restored that, browsing the to site gives a 404 error for all resources in the Media
folder. Why?
Source: (StackOverflow)