The effect of porosity on the properties of solids is an established factor and is the subject of numerous studies because of great theoretical and applied interest. The presence of pores in the sample can lead to a significant decrease in its strength, because of the stress concentration at the pore boundaries, especially if their shape is far from spherical. However, computational models of porous structures do not always take due account of the effects of a significant dependence of the porosity on the stress state. In this paper, variant of the applied theory of porous media is proposed, which was constructed as a special case of the theory of media with conserved dislocations. A mathematical formulation of the theory of porous media is given, which includes defining equations, equilibrium equations and boundary conditions. We study the correct particular model of porous media with a microstructure (as defined by Mindlin). Variational approach is used to build the model, which is an effective tool for modeling environments of varying complexity, allowing obtaining energy-matched mathematical models. The physical interpretation of the model is related to the refined description of the stress-strain state of porous media in which the volume content of porosity varies under the action of applied external loads. Based on the presented results, it is shown that the analytical solution allows obtaining fairly accurate estimates for predicting the effect of nonclassical scale and surface effects on the effective stiffness and stress state of a porous medium. The scale effects are determined by the gradient nonlocality, which arises when allowance is made for the fields of free deformations associated with different defect fields (or with structural features of the material). As an example, the problem of uniaxial and biaxial stretching of a porous strip is considered.