Rack is a basic interface between web servers and Ruby frameworks. Middlewares are filters that can intercept a request and alter the response. Common middlewares include Rack::Cache for caching and Rack::ETag for handling ETags. Developers can also create their own custom middlewares to add functionality to Rack and Ruby on Rails applications.